-
Notifications
You must be signed in to change notification settings - Fork 125
226 lines (212 loc) · 8.4 KB
/
release-version.yml
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# This workflow expects a version tag like "v0.4.0" or "v0.3.0-nightly".
# If the version doesn't have a pre-release part (that is it doesn't have any "-") then a full release will be performed.
# Otherwise it will create and upload an internal build.
name: Release
on:
workflow_dispatch:
inputs:
packages_merge_base:
description: 'Base branch to merge update deployed packages to (no merging if not specified)'
required: false
default: 'main'
packages_merge_revert:
description: 'Revert version back to the specified version (you should only use this for merging to main)'
required: false
default: true
type: boolean
push:
tags: [v*]
branches:
# For workflow testing only
# This is to simulate pushing to a tag
- WORKFLOW-TESTING/release-version/v*
permissions:
actions: write
contents: write
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
meta:
runs-on: ubuntu-22.04
outputs:
kind: ${{ steps.extract.outputs.kind }}
tag: ${{ steps.extract.outputs.tag }}
version: ${{ steps.extract.outputs.version }}
steps:
- name: Extract tag and version
id: extract
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
tag=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/WORKFLOW-TESTING/release-version/* ]]; then
# This is a special case for testing only
tag=${GITHUB_REF#refs/heads/WORKFLOW-TESTING/release-version/}
else
echo "Triggered for unexpected git ref"
exit 1
fi
# Version is the tag without the v
version=${tag#v}
if [[ $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+-(rc|alpha|beta)(\..*)?$ ]]; then
# few special cases for full versions, for example: v0.3.0-rc v0.3.0-rc.1 v0.3.0-alpha v0.3.0-beta
# but not: v0.3.0-rcNot
kind=full
elif [[ $tag == v*-* ]]; then
# otherwise anything with a dash is internal, for example: v0.3.0-nightly-2023-09-29
kind=internal
else
# no dashes then it's a plain old full version, for example: v0.3.0
kind=full
fi
echo "kind=${kind}" >> $GITHUB_OUTPUT
echo "tag=${tag}" >> $GITHUB_OUTPUT
echo "version=${version}" >> $GITHUB_OUTPUT
# print out what was set
echo "kind=${kind}"
echo "tag=${tag}"
echo "version=${version}"
build-app:
needs: meta
permissions:
id-token: write
strategy:
matrix:
include:
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
exe_name: ambient
symbol_path: ambient
- os: macos-latest
target: aarch64-apple-darwin
exe_name: ambient
symbol_path: ambient
- os: windows-latest
target: x86_64-pc-windows-msvc
exe_name: ambient.exe
symbol_path: ambient.pdb
runs-on: ${{ matrix.os }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXE_DIR: target/${{ matrix.target }}/release
steps:
- name: Setup Sentry CLI
uses: mathieu-bour/[email protected]
with:
token: ${{ secrets.SENTRY }}
organization: dims
project: native-client
- uses: actions/checkout@v3
- name: Install build dependencies
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y libasound2-dev libglib2.0-dev libxcb-shape0-dev libxcb-xfixes0-dev \
libcairo-dev libgtk2.0-dev libsoup2.4-dev libgtk-3-dev libwebkit2gtk-4.0-dev xorg-dev ninja-build libxcb-render0-dev
- name: Install aarch64-apple-darwin
if: matrix.target == 'aarch64-apple-darwin'
run: rustup target add aarch64-apple-darwin
- uses: dtolnay/rust-toolchain@stable
# We don't do caching here because we only have 10gb and they'll be occupied by normal builds all the time anyway
- name: Build
run: cargo build --release -p ambient --target ${{ matrix.target }} --features production
- name: Code Sign Windows
if: ${{ matrix.os == 'windows-latest' }}
uses: sslcom/esigner-codesign@develop
with:
command: sign
username: ${{secrets.ES_USERNAME}}
password: ${{secrets.ES_PASSWORD}}
credential_id: ${{secrets.ES_CREDENTIAL_ID}}
totp_secret: ${{secrets.ES_TOTP_SECRET}}
file_path: ${{ env.EXE_DIR }}/${{ matrix.exe_name }}
dir_path: ${{ env.EXE_DIR }}
override: true
malware_block: false
- name: Install certificate (OSX)
if: matrix.os == 'macos-latest'
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.MACOS_CERTIFICATE }}
p12-password: ${{ secrets.MACOS_CERTIFICATE_PWD }}
- name: Codesign executable (OSX)
if: matrix.os == 'macos-latest'
run: /usr/bin/codesign --force -s ${{ secrets.MAC_CODESIGN }} --options=runtime --entitlements app/osx_entitlements.xml --deep ${{ env.EXE_DIR }}/${{ matrix.exe_name }} -v
- name: Bundle
uses: thedoctor0/[email protected]
with:
type: "zip"
filename: ambient-${{ matrix.target }}.zip
directory: ${{ env.EXE_DIR }}
path: ${{ matrix.exe_name }}
- name: Notarize app bundle (OSX)
if: matrix.os == 'macos-latest'
run: |
cd ${{ env.EXE_DIR }}
xcrun notarytool store-credentials "notarytool-profile" --apple-id "${{ secrets.APPLE_DEVELOPER_EMAIL }}" --team-id="${{ secrets.APPLE_TEAM_ID }}" --password "${{ secrets.APPLE_DEVELOPER_PASSWORD }}"
xcrun notarytool submit "ambient-${{ matrix.target }}.zip" --keychain-profile "notarytool-profile" --wait
- name: Authenticate with Google Cloud
id: auth
uses: google-github-actions/auth@v0
with:
token_format: access_token
workload_identity_provider: projects/549180905870/locations/global/workloadIdentityPools/github-pool/providers/github-provider
service_account: [email protected]
access_token_lifetime: 1800s
- name: Upload to Google Cloud
uses: google-github-actions/upload-cloud-storage@v1
with:
path: ${{ env.EXE_DIR }}/ambient-${{ matrix.target }}.zip
destination: "ambient-artifacts/ambient-builds/${{ needs.meta.outputs.version }}/${{ matrix.os }}"
- name: Upload debug symbols
run: sentry-cli upload-dif -o dims -p native-client ${{ env.EXE_DIR }}/${{ matrix.exe_name }} ${{ env.EXE_DIR }}/${{ matrix.symbol_path }}
trigger-deploy-packages-jobs:
needs: meta
runs-on: ubuntu-22.04
steps:
- name: Trigger deploy packages job
uses: actions/github-script@v6
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'deploy-packages.yml',
ref: '${{ needs.meta.outputs.tag }}',
inputs: {
base: '${{ github.event.inputs.packages_merge_base || 'main' }}',
revert: ${{ github.event.inputs.packages_merge_revert == 'true' }},
},
})
trigger-build-jobs:
needs: meta
runs-on: ubuntu-22.04
steps:
- name: Trigger build jobs
uses: actions/github-script@v6
with:
script: |
for (const workflow_id of ['deploy-server.yml', 'deploy-web.yml', 'deploy-docs.yml']) {
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflow_id,
ref: '${{ needs.meta.outputs.tag }}',
})
}
publish-api:
if: needs.meta.outputs.kind == 'full'
needs: [meta, build-app]
runs-on: ubuntu-22.04
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'publish-api.yml',
ref: '${{ needs.meta.outputs.tag }}',
})