-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (154 loc) · 6.43 KB
/
grafbase-partial-release.yml
File metadata and controls
174 lines (154 loc) · 6.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Grafbase Release
on:
workflow_call:
inputs:
draft:
type: boolean
required: true
prerelease:
type: boolean
required: true
tag:
type: string
required: true
secrets:
CRATES_ACCESS_TOKEN:
required: true
NPM_ACCESS_TOKEN:
required: true
CLOUDFLARE_ASSETS_ACCOUNT_ID:
required: true
CLOUDFLARE_ASSETS_R2_ACCESS_KEY_ID:
required: true
CLOUDFLARE_ASSETS_R2_SECRET_ACCESS_KEY:
required: true
jobs:
release:
name: Release grafbase
runs-on: ubicloud-standard-2
steps:
- name: Parse version tag
run: |
VERSION_BUMP="${{ inputs.tag }}"
VERSION_BUMP=${VERSION_BUMP//grafbase-} # remove the grafbase prefix from the tag
echo VERSION_BUMP=${VERSION_BUMP} >> $GITHUB_ENV
- name: Announce release attempt on Slack
uses: ravsamhq/notify-slack-action@v2
with:
notification_title: '({workflow}) grafbase release for ${{ env.VERSION_BUMP }} started'
footer: '<{run_url}|View Run>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Get sources
uses: actions/checkout@v4
- name: Rust job init
uses: ./.github/actions/init_rust_job
with:
platform: linux
cache-key: ${{ runner.os }}-${{ runner.arch }}-cargo-release-${{ hashFiles('Cargo.lock') }}
restore-key: ${{ runner.os }}-${{ runner.arch }}-cargo-release
# This is annoying, but github doesn't pass env vars down to child workflows,
# and you can't use them as input parameters either so lets read them out the
# YAML
- name: Get PROD_ASSETS from binaries workflow
id: lookup-prod-assets
uses: mikefarah/yq@master
with:
cmd: yq '.env.PROD_ASSETS' './.github/workflows/binaries.yml'
- name: Build assets
uses: ./.github/actions/cli_assets
- name: Download darwin-x86_64 artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.VERSION_BUMP }}-x86_64-apple-darwin
path: cli/npm/x86_64-apple-darwin
- name: Download darwin-aarch64 artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.VERSION_BUMP }}-aarch64-apple-darwin
path: cli/npm/aarch64-apple-darwin
- name: Download Linux AMD artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.VERSION_BUMP }}-linux
path: cli/npm/x86_64-unknown-linux-musl
- name: Download Linux ARM artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.VERSION_BUMP }}-linux-arm
path: cli/npm/aarch64-unknown-linux-musl
- name: Download windows artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.VERSION_BUMP }}-x86_64-pc-windows-msvc
path: cli/npm/x86_64-pc-windows-msvc
- name: Process artifacts
shell: bash
run: |
cd cli/npm
mkdir github
cp aarch64-apple-darwin/grafbase github/grafbase-aarch64-apple-darwin
cp x86_64-apple-darwin/grafbase github/grafbase-x86_64-apple-darwin
cp x86_64-pc-windows-msvc/grafbase.exe github/grafbase-x86_64-pc-windows-msvc.exe
cp x86_64-unknown-linux-musl/grafbase github/grafbase-x86_64-unknown-linux-musl
cp aarch64-unknown-linux-musl/grafbase github/grafbase-aarch64-unknown-linux-musl
chmod +x aarch64-apple-darwin/grafbase
chmod +x x86_64-apple-darwin/grafbase
chmod +x x86_64-unknown-linux-musl/grafbase
chmod +x aarch64-unknown-linux-musl/grafbase
- name: Install cargo-binstall and cargo-about
shell: bash
run: |
curl -LsSf https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
cargo binstall --no-symlinks --no-confirm cargo-about
- name: Generate licenses
shell: bash
run: |
cargo about generate -c cli/about.toml -o "licenses.html" cli/about.hbs
find cli/crates -maxdepth 1 -type d -exec cp cli/licenses.html {} \;
find cli/npm -maxdepth 1 -type d -exec cp cli/licenses.html {} \;
- name: Publish npm
shell: bash
env:
INPUT_PRERELEASE: ${{ inputs.prerelease && 'true' || 'false' }}
run: |
npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_ACCESS_TOKEN }}
cd cli/npm
PUBLISH_ARGUMENTS=()
if [[ $INPUT_PRERELEASE != "false" ]]; then
echo "Running prerelease: $INPUT_PRERELEASE"
PUBLISH_ARGUMENTS+=(--tag next)
fi
(cd aarch64-apple-darwin && npm publish "${PUBLISH_ARGUMENTS[@]}")
(cd x86_64-apple-darwin && npm publish "${PUBLISH_ARGUMENTS[@]}")
(cd x86_64-pc-windows-msvc && npm publish "${PUBLISH_ARGUMENTS[@]}")
(cd x86_64-unknown-linux-musl && npm publish "${PUBLISH_ARGUMENTS[@]}")
(cd aarch64-unknown-linux-musl && npm publish "${PUBLISH_ARGUMENTS[@]}")
(cd cli && npm publish "${PUBLISH_ARGUMENTS[@]}")
- name: Github release
id: gh-release-grafbase
uses: softprops/action-gh-release@v2
with:
body_path: cli/changelog/${{ env.VERSION_BUMP }}.md
draft: ${{ inputs.draft }}
prerelease: ${{ inputs.prerelease }}
files: |
licenses.html
cli/npm/github/grafbase-aarch64-apple-darwin
cli/npm/github/grafbase-x86_64-apple-darwin
cli/npm/github/grafbase-x86_64-pc-windows-msvc.exe
cli/npm/github/grafbase-x86_64-unknown-linux-musl
cli/npm/github/grafbase-aarch64-unknown-linux-musl
- name: Publish CLI install script
shell: bash
env:
INPUT_PRERELEASE: ${{ inputs.prerelease && 'true' || 'false' }}
CLOUDFLARE_ASSETS_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ASSETS_ACCOUNT_ID }}
CLOUDFLARE_ASSETS_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_ASSETS_R2_ACCESS_KEY_ID }}
CLOUDFLARE_ASSETS_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_ASSETS_R2_SECRET_ACCESS_KEY }}
run: |
if [[ $INPUT_PRERELEASE == "false" ]]; then
cd cli/install
sed -i 's/{{LATEST_VERSION}}/${{ env.VERSION_BUMP }}/g' cli
./upload.sh cli
fi