Skip to content

Commit 375cfd3

Browse files
authored
Update release-os12.yml
1 parent 21675de commit 375cfd3

File tree

1 file changed

+261
-0
lines changed

1 file changed

+261
-0
lines changed

.github/workflows/release-os12.yml

Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,262 @@
1+
name: Release
12

3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
isNightly:
7+
description: "Is this a nightly version or a release - Y or N"
8+
type: string
9+
required: true
10+
default: "Y"
11+
version:
12+
description: "stable version for the build"
13+
type: string
14+
required: false
15+
default: "v0.3.0"
16+
17+
env:
18+
CARGO_TERM_COLOR: always
19+
IS_NIGHTLY: ${{ inputs.isNightly == 'Y' }}
20+
PROFILE: maxperf
21+
STABLE_VERSION: ${{ inputs.version }}
22+
23+
jobs:
24+
prepare:
25+
name: Prepare release
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 30
28+
outputs:
29+
tag_name: ${{ steps.release_info.outputs.tag_name }}
30+
release_name: ${{ steps.release_info.outputs.release_name }}
31+
changelog: ${{ steps.build_changelog.outputs.changelog }}
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Compute release name and tag
38+
id: release_info
39+
run: |
40+
if [[ ${IS_NIGHTLY} == 'true' ]]; then
41+
echo "tag_name=nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT
42+
echo "release_name=Nightly ($(date '+%Y-%m-%d'))" >> $GITHUB_OUTPUT
43+
else
44+
echo "tag_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
45+
echo "release_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
46+
fi
47+
48+
# Creates a `nightly-SHA` tag for this specific nightly
49+
# This tag is used for this specific nightly version's release
50+
# which allows users to roll back. It is also used to build
51+
# the changelog.
52+
- name: Create build-specific nightly tag
53+
if: ${{ env.IS_NIGHTLY == 'true' }}
54+
uses: actions/github-script@v7
55+
env:
56+
TAG_NAME: ${{ steps.release_info.outputs.tag_name }}
57+
with:
58+
script: |
59+
const createTag = require('./.github/scripts/create-tag.js')
60+
await createTag({ github, context }, process.env.TAG_NAME)
61+
62+
- name: Build changelog
63+
id: build_changelog
64+
uses: mikepenz/release-changelog-builder-action@v4
65+
with:
66+
configuration: "./.github/changelog.json"
67+
fromTag: ${{ env.IS_NIGHTLY == 'true' && 'nightly' || env.STABLE_VERSION }}
68+
toTag: ${{ steps.release_info.outputs.tag_name }}
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
72+
release:
73+
permissions:
74+
id-token: write
75+
contents: write
76+
attestations: write
77+
name: ${{ matrix.target }} (${{ matrix.runner }})
78+
runs-on: ${{ matrix.runner }}
79+
timeout-minutes: 240
80+
needs: prepare
81+
strategy:
82+
fail-fast: false
83+
matrix:
84+
include:
85+
# `runner`: GHA runner label
86+
# `target`: Rust build target triple
87+
# `platform` and `arch`: Used in tarball names
88+
# `svm`: target platform to use for the Solc binary: https://github.com/roynalnaruto/svm-rs/blob/84cbe0ac705becabdc13168bae28a45ad2299749/svm-builds/build.rs#L4-L24
89+
- runner: macos-14
90+
target: x86_64-apple-darwin
91+
svm_target_platform: macosx-amd64
92+
platform: darwin
93+
arch: amd64
94+
steps:
95+
- uses: actions/checkout@v4
96+
- uses: dtolnay/rust-toolchain@stable
97+
with:
98+
targets: ${{ matrix.target }}
99+
- uses: Swatinem/rust-cache@v2
100+
with:
101+
key: ${{ matrix.target }}
102+
cache-on-failure: true
103+
104+
- name: Apple M1 setup
105+
if: matrix.target == 'aarch64-apple-darwin'
106+
run: |
107+
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
108+
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
109+
110+
- name: Linux ARM setup musl x86_64
111+
if: matrix.target == 'x86_64-unknown-linux-musl'
112+
run: |
113+
sudo apt-get update -y
114+
sudo apt-get install -y musl-tools
115+
116+
- name: Build binaries
117+
env:
118+
TAG_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }}
119+
SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }}
120+
PLATFORM_NAME: ${{ matrix.platform }}
121+
TARGET: ${{ matrix.target }}
122+
OUT_DIR: target/${{ matrix.target }}/${{ env.PROFILE }}
123+
shell: bash
124+
run: |
125+
set -eo pipefail
126+
flags=(--target $TARGET --profile $PROFILE --bins
127+
--no-default-features --features aws-kms,cli,asm-keccak)
128+
129+
# `jemalloc` is not fully supported on MSVC or aarch64 Linux.
130+
if [[ "$TARGET" != *msvc* && "$TARGET" != "aarch64-unknown-linux-gnu" ]]; then
131+
flags+=(--features jemalloc)
132+
fi
133+
134+
[[ "$TARGET" == *windows* ]] && ext=".exe"
135+
136+
cargo build "${flags[@]}"
137+
138+
bins=(cast forge)
139+
for name in "${bins[@]}"; do
140+
bin=$OUT_DIR/$name$ext
141+
echo ""
142+
file "$bin" || true
143+
du -h "$bin" || true
144+
ldd "$bin" || true
145+
$bin --version || true
146+
echo "${name}_bin_path=${bin}" >> $GITHUB_ENV
147+
done
148+
149+
- name: Archive binaries
150+
id: artifacts
151+
env:
152+
PLATFORM_NAME: ${{ matrix.platform }}
153+
OUT_DIR: target/${{ matrix.target }}/${{ env.PROFILE }}
154+
VERSION_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }}
155+
ARCH: ${{ matrix.arch }}
156+
shell: bash
157+
run: |
158+
if [ "$PLATFORM_NAME" == "linux" ]; then
159+
tar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C $OUT_DIR forge cast
160+
echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT
161+
elif [ "$PLATFORM_NAME" == "darwin" ]; then
162+
# We need to use gtar here otherwise the archive is corrupt.
163+
# See: https://github.com/actions/virtual-environments/issues/2619
164+
gtar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C $OUT_DIR forge cast
165+
echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT
166+
else
167+
cd $OUT_DIR
168+
7z a -tzip "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" forge.exe cast.exe
169+
mv "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" ../../../
170+
echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" >> $GITHUB_OUTPUT
171+
fi
172+
173+
- name: Build man page
174+
id: man
175+
if: matrix.target == 'x86_64-unknown-linux-gnu'
176+
env:
177+
OUT_DIR: target/${{ matrix.target }}/${{ env.PROFILE }}
178+
VERSION_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }}
179+
shell: bash
180+
run: |
181+
sudo apt-get -y install help2man
182+
help2man -N $OUT_DIR/forge > forge.1
183+
help2man -N $OUT_DIR/cast > cast.1
184+
gzip forge.1
185+
gzip cast.1
186+
tar -czvf "foundry_man_${VERSION_NAME}.tar.gz" forge.1.gz cast.1.gz
187+
echo "foundry_man=foundry_man_${VERSION_NAME}.tar.gz" >> $GITHUB_OUTPUT
188+
189+
# Creates the release for this specific version
190+
- name: Create release
191+
uses: softprops/action-gh-release@v2
192+
with:
193+
name: ${{ needs.prepare.outputs.release_name }}
194+
tag_name: ${{ needs.prepare.outputs.tag_name }}
195+
prerelease: ${{ env.IS_NIGHTLY == 'true' }}
196+
body: ${{ needs.prepare.outputs.changelog }}
197+
files: |
198+
${{ steps.artifacts.outputs.file_name }}
199+
${{ steps.man.outputs.foundry_man }}
200+
201+
- name: Binaries attestation
202+
uses: actions/attest-build-provenance@v2
203+
with:
204+
subject-path: |
205+
${{ env.cast_bin_path }}
206+
${{ env.forge_bin_path }}
207+
208+
# If this is a nightly release, it also updates the release
209+
# tagged `nightly` for compatibility with `foundryup`
210+
- name: Update nightly release
211+
if: ${{ env.IS_NIGHTLY == 'true' }}
212+
uses: softprops/action-gh-release@v2
213+
with:
214+
name: "Nightly"
215+
tag_name: "nightly"
216+
prerelease: true
217+
body: ${{ needs.prepare.outputs.changelog }}
218+
files: |
219+
${{ steps.artifacts.outputs.file_name }}
220+
${{ steps.man.outputs.foundry_man }}
221+
222+
cleanup:
223+
name: Release cleanup
224+
runs-on: ubuntu-latest
225+
timeout-minutes: 30
226+
needs: release
227+
if: always()
228+
steps:
229+
- uses: actions/checkout@v4
230+
231+
# Moves the `nightly` tag to `HEAD`
232+
- name: Move nightly tag
233+
if: ${{ env.IS_NIGHTLY == 'true' }}
234+
uses: actions/github-script@v7
235+
with:
236+
script: |
237+
const moveTag = require('./.github/scripts/move-tag.js')
238+
await moveTag({ github, context }, 'nightly')
239+
240+
- name: Delete old nightlies
241+
uses: actions/github-script@v7
242+
with:
243+
script: |
244+
const prunePrereleases = require('./.github/scripts/prune-prereleases.js')
245+
await prunePrereleases({github, context})
246+
247+
# If any of the jobs fail, this will create a high-priority issue to signal so.
248+
issue:
249+
name: Open an issue
250+
runs-on: ubuntu-latest
251+
needs: [ prepare, release, cleanup ]
252+
if: failure()
253+
steps:
254+
- uses: actions/checkout@v4
255+
- uses: JasonEtco/create-an-issue@v2
256+
env:
257+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
258+
WORKFLOW_URL: |
259+
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
260+
with:
261+
update_existing: true
262+
filename: .github/RELEASE_FAILURE_ISSUE_TEMPLATE.md

0 commit comments

Comments
 (0)