-
Notifications
You must be signed in to change notification settings - Fork 63
295 lines (261 loc) · 12.4 KB
/
release.yml
File metadata and controls
295 lines (261 loc) · 12.4 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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: Build IOTA binaries
run-name: Build IOTA binaries for ${{ inputs.iota_branch || github.ref }}
on:
release:
types: [created]
schedule:
- cron: "0 4 * * *" # Runs every day at 4 AM
workflow_dispatch:
inputs:
iota_branch:
description: "Branch to build from"
type: string
required: true
concurrency: ${{ github.workflow }}-${{ inputs.iota_branch || github.ref }}
env:
BINARY_LIST_FILE: "./binary-build-list.json"
CARGO_TERM_COLOR: always
RUST_LOG: "error"
# Don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short
# Disable incremental compilation.
#
# Incremental compilation is useful as part of an edit-build-test-edit cycle,
# as it lets the compiler avoid recompiling code that hasn't changed. However,
# on CI, we're not making small edits; we're almost always building the entire
# project from scratch. Thus, incremental compilation on CI actually
# introduces *additional* overhead to support making future builds
# faster...but no future builds will ever occur in any given CI environment.
#
# See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
# for details.
CARGO_INCREMENTAL: 0
# Allow more retries for network requests in cargo (downloading crates) and
# rustup (installing toolchains). This should help to reduce flaky CI failures
# from transient network timeouts or other issues.
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
# Path to temporary build directory. If this gets changed the chocolatey nuspec files needs to be updated
TMP_BUILD_DIR: "./tmp/release"
RELEASE_NOTES_FILE: "release_notes.txt"
jobs:
generate-tag:
runs-on: ubuntu-latest
outputs:
iota_ref: ${{ steps.ref.outputs.iota_ref }}
steps:
- name: Clean up and validate ref to build and create artifact name
id: ref
shell: bash
run: |
# Manual dispatch on a branch ref
if [ "${{ github.event_name == 'workflow_dispatch' }}" == "true" ]; then
echo "iota_ref=${{ inputs.iota_branch }}" >> $GITHUB_OUTPUT
fi
# Release builds on a tag ref
if [ "${{ github.event_name == 'release' }}" == "true" ]; then
export iota_ref=$(echo ${{ github.ref }} | sed s/'refs\/tags\/'// )
echo "iota_ref=${iota_ref}" >> $GITHUB_OUTPUT
fi
# Scheduled nightly builds are always cut from develop
if [ "${{ github.event_name == 'schedule' }}" == "true" ]; then
echo "iota_ref=develop" >> $GITHUB_OUTPUT
fi
release-build:
name: Build Binaries
timeout-minutes: 240
strategy:
matrix:
include:
- os: self-hosted-x64
os_type: linux-x86_64
- os: self-hosted-arm64
os_type: linux-arm64
- os: macos-latest
os_type: macos-arm64
- os: windows-latest
os_type: windows-x86_64
continue-on-error: true
fail-fast: false
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.continue-on-error == true }}
needs: generate-tag
steps:
- name: Create artifact name
id: create-artifact
shell: bash
run: |
# Manual dispatch on a branch ref
if [ "${{ github.event_name == 'workflow_dispatch' }}" == "true" ]; then
echo "artifact_name=iota-$(echo ${{ inputs.iota_branch }} | tr "/" "-")-${{ matrix.os_type }}" >> $GITHUB_OUTPUT
fi
# Release builds on a tag ref
if [ "${{ github.event_name == 'release' }}" == "true" ]; then
echo "artifact_name=iota-${{ needs.generate-tag.outputs.iota_ref }}-${{ matrix.os_type }}" >> $GITHUB_OUTPUT
fi
# Scheduled nightly builds are always cut from develop
if [ "${{ github.event_name == 'schedule' }}" == "true" ]; then
echo "artifact_name=iota-nightly-$(date -Idate)-${{ matrix.os_type }}" >> $GITHUB_OUTPUT
fi
- name: Check out ${{ needs.generate-tag.outputs.iota_ref }}
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
ref: ${{ needs.generate-tag.outputs.iota_ref }}
- name: Set os/arch variables (Windows)
if: ${{ matrix.os_type == 'windows-x86_64' }}
shell: bash
run: |
echo "extension=$(echo ".exe")" >> $GITHUB_ENV
- name: Install postgres (Windows)
if: ${{ matrix.os_type == 'windows-x86_64' }}
shell: bash
run: |
choco install postgresql15 --force --params '/Password:root'
echo "C:\Program Files\PostgreSQL\15\bin" >> $GITHUB_PATH
echo "C:\Program Files\PostgreSQL\15\lib" >> $GITHUB_PATH
echo "PQ_LIB_DIR=C:\Program Files\PostgreSQL\15\lib" >> $GITHUB_ENV
echo "PG_DATABASE_URL=postgres://postgres:root@localhost/" >> $GITHUB_ENV
echo "PG_EXAMPLE_DATABASE_URL=postgres://postgres:root@localhost/diesel_example" >> $GITHUB_ENV
- name: Install postgres (MacOS arm64)
if: ${{ matrix.os_type == 'macos-arm64' }}
shell: bash
run: |
brew install postgresql@15
PQ_PREFIX="$(brew --prefix libpq)"
echo "PQ_LIB_DIR=${PQ_PREFIX}/lib" >> $GITHUB_ENV
echo "LIBRARY_PATH=${PQ_PREFIX}/lib${LIBRARY_PATH:+:$LIBRARY_PATH}" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=${PQ_PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" >> $GITHUB_ENV
echo "${PQ_PREFIX}/bin" >> $GITHUB_PATH
- name: Install protoc (Windows)
if: ${{ matrix.os_type == 'windows-x86_64' }}
uses: taiki-e/install-action@protoc
- name: Install protoc (MacOS arm64)
if: ${{ matrix.os_type == 'macos-arm64' }}
uses: taiki-e/install-action@protoc
- name: Remove unused apps (MacOS arm64)
if: ${{ matrix.os_type == 'macos-arm64' }}
continue-on-error: true
shell: bash
run: |
# MacOS arm64 runner only has 14GB available, which is too small for our builds, so removing unused software.
df -h /
sudo rm -rf /Applications/Xcode*.app
sudo rm -rf ~/Library/Developer/Xcode/DerivedData
sudo rm -rf ~/Library/Developer/CoreSimulator/Caches/*
sudo rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport/*
df -h /
- name: Cargo build for ${{ matrix.os_type }} platform
shell: bash
run: |
[ -f ~/.cargo/env ] && source ~/.cargo/env
jq -r '.release_binaries | to_entries[] | [.key, (.value | join(","))] | @tsv' ${{ env.BINARY_LIST_FILE }} | while IFS=$'\t' read -r binary features; do
echo ">>> Building $binary with features: $features"
if [[ -z "$features" ]]; then
cargo build --release --bin "$binary"
else
cargo build --release --bin "$binary" --features "$features"
fi
done
- name: Rename binaries for ${{ matrix.os_type }}
shell: bash
run: |
mkdir -p ${{ env.TMP_BUILD_DIR }}
[ ! -f ${{ env.BINARY_LIST_FILE }} ] && echo "${{ env.BINARY_LIST_FILE }} cannot be found" && exit 1
jq -r '.release_binaries | keys[]' ${{ env.BINARY_LIST_FILE }} | while read -r binary; do
export binary=$(echo ${binary} | tr -d $'\r')
mv ./target/release/${binary}${{ env.extension }} ${{ env.TMP_BUILD_DIR }}/${binary}${{ env.extension }}
done
tar -cvzf ./tmp/${{ steps.create-artifact.outputs.artifact_name }}.tgz -C ${{ env.TMP_BUILD_DIR }} .
- name: Upload artifacts for ${{ matrix.os_type }} platform
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: ${{ steps.create-artifact.outputs.artifact_name }}
if-no-files-found: error
path: |
./tmp/${{ steps.create-artifact.outputs.artifact_name }}.tgz
- name: Attach artifacts to ${{ needs.generate-tag.outputs.iota_ref }} release in GH
if: ${{ github.event_name == 'release' }}
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
with:
tag_name: ${{ needs.generate-tag.outputs.iota_ref }}
files: |
./tmp/${{ steps.create-artifact.outputs.artifact_name }}.tgz
generate-release-notes:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PRERELEASE: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') }}
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' }}
needs: generate-tag
steps:
- name: Check out ${{ needs.generate-tag.outputs.iota_ref }}
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
ref: ${{ needs.generate-tag.outputs.iota_ref }}
- name: Generate release notes
run: |
new_commit_hash=$(git rev-parse HEAD)
echo "New commit hash: $new_commit_hash"
iota_tag="$(echo ${{ needs.generate-tag.outputs.iota_ref }} | sed s/'refs\/tags\/'//)"
echo "iota_tag = $iota_tag"
trl=$(echo "$iota_tag" | sed -n 's/^[^-]*\(-.*\)/\1/p')
echo "trl = $trl"
current_minor=$(echo "$iota_tag" | sed -E 's/^v[0-9]+\.([0-9]+)\..*/\1/')
current_major=$(echo "$iota_tag" | sed -E 's/^v([0-9]+)\..*/\1/')
previous_minor=$((current_minor - 1))
echo "Current major: $current_major, current minor: $current_minor, previous minor: $previous_minor"
previous_tag=$(git tag --sort=-version:refname | grep -E "^v${current_major}\.${previous_minor}\.[0-9]+${trl}$" | head -n 1)
echo "Previous tag: $previous_tag"
previous_commit_hash=$(git rev-list -n 1 "${previous_tag}")
echo "Previous commit hash: $previous_commit_hash"
pushd "scripts/release_notes" > /dev/null
./run.sh generate $previous_commit_hash $new_commit_hash | tee -a "../../${{ env.RELEASE_NOTES_FILE }}" > /dev/null
popd > /dev/null
echo "---" >> ${{ env.RELEASE_NOTES_FILE }}
echo "#### Full Log: https://github.com/iotaledger/iota/compare/$previous_tag...${{ needs.generate-tag.outputs.iota_ref }}" >> ${{ env.RELEASE_NOTES_FILE }}
echo "Generated notes:\n---"
cat ${{ env.RELEASE_NOTES_FILE }}
- name: Add release notes to ${{ needs.generate-tag.outputs.iota_ref }} release in GH
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
with:
tag_name: ${{ needs.generate-tag.outputs.iota_ref }}
body_path: ${{ env.RELEASE_NOTES_FILE }}
prerelease: ${{ env.PRERELEASE }}
update-homebrew-formula:
name: Update the homebrew-tap formula
needs: release-build
runs-on: ubuntu-latest
# Releasing iota cli on Testnet and Mainnet releases which are equally stable.
# Windows uses continue-on-error so its failure won't affect the matrix result.
if: ${{ github.event_name == 'release' && !contains(github.ref, '-alpha') && !contains(github.ref, '-beta')}}
steps:
- name: Install Homebrew
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH
- name: Install github CLI
run: brew install gh
- name: Get tag for the release
id: tag
shell: bash
run: |
echo iota_tag="$(echo ${{ github.ref }} | sed s/'refs\/tags\/'//)" >> $GITHUB_OUTPUT
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Get binary checksums
uses: thewh1teagle/checksum@6577963a29f57d780d12a2e5495601298ba739d1 # v2
with:
tag: ${{ steps.tag.outputs.iota_tag }}
# These two parameters are needed to make the resulting checksum file work with shasum256 -c
reverse-order: true
separator: " "
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: ./scripts/homebrew/update_formula.sh ${{ steps.tag.outputs.iota_tag }}
env:
# GH_TOKEN needs write access to the repository specified by the homebrew-tap input,
# or enough privileges to fork the tap repo (usually homebrew-core) and submit a PR to it.
# Recommended "classic" token scopes: repo & workflow.
# https://github.com/settings/tokens/new?scopes=public_repo,workflow
GH_TOKEN: ${{ secrets.HOMEBREW_GH_FORMULA_BUMP }}