|
| 1 | +name: Release |
1 | 2 |
|
| 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: ubuntu-24.04 |
| 90 | + target: x86_64-unknown-linux-musl |
| 91 | + svm_target_platform: linux-amd64 |
| 92 | + platform: linux |
| 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 | + sudo apt-get install kernal-headers |
| 116 | +
|
| 117 | + - name: Build binaries |
| 118 | + env: |
| 119 | + TAG_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }} |
| 120 | + SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} |
| 121 | + PLATFORM_NAME: ${{ matrix.platform }} |
| 122 | + TARGET: ${{ matrix.target }} |
| 123 | + OUT_DIR: target/${{ matrix.target }}/${{ env.PROFILE }} |
| 124 | + shell: bash |
| 125 | + run: | |
| 126 | + set -eo pipefail |
| 127 | + flags=(--target $TARGET --profile $PROFILE --bins |
| 128 | + --no-default-features --features aws-kms,cli,asm-keccak) |
| 129 | +
|
| 130 | + # `jemalloc` is not fully supported on MSVC or aarch64 Linux. |
| 131 | + if [[ "$TARGET" != *msvc* && "$TARGET" != "aarch64-unknown-linux-gnu" ]]; then |
| 132 | + flags+=(--features jemalloc) |
| 133 | + fi |
| 134 | +
|
| 135 | + [[ "$TARGET" == *windows* ]] && ext=".exe" |
| 136 | +
|
| 137 | + cargo build "${flags[@]}" |
| 138 | +
|
| 139 | + bins=(cast forge) |
| 140 | + for name in "${bins[@]}"; do |
| 141 | + bin=$OUT_DIR/$name$ext |
| 142 | + echo "" |
| 143 | + file "$bin" || true |
| 144 | + du -h "$bin" || true |
| 145 | + ldd "$bin" || true |
| 146 | + $bin --version || true |
| 147 | + echo "${name}_bin_path=${bin}" >> $GITHUB_ENV |
| 148 | + done |
| 149 | +
|
| 150 | + - name: Archive binaries |
| 151 | + id: artifacts |
| 152 | + env: |
| 153 | + PLATFORM_NAME: ${{ matrix.platform }} |
| 154 | + OUT_DIR: target/${{ matrix.target }}/${{ env.PROFILE }} |
| 155 | + VERSION_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }} |
| 156 | + ARCH: ${{ matrix.arch }} |
| 157 | + shell: bash |
| 158 | + run: | |
| 159 | + if [ "$PLATFORM_NAME" == "linux" ]; then |
| 160 | + tar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C $OUT_DIR forge cast |
| 161 | + echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT |
| 162 | + elif [ "$PLATFORM_NAME" == "darwin" ]; then |
| 163 | + # We need to use gtar here otherwise the archive is corrupt. |
| 164 | + # See: https://github.com/actions/virtual-environments/issues/2619 |
| 165 | + gtar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C $OUT_DIR forge cast |
| 166 | + echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT |
| 167 | + else |
| 168 | + cd $OUT_DIR |
| 169 | + 7z a -tzip "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" forge.exe cast.exe |
| 170 | + mv "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" ../../../ |
| 171 | + echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" >> $GITHUB_OUTPUT |
| 172 | + fi |
| 173 | +
|
| 174 | + - name: Build man page |
| 175 | + id: man |
| 176 | + if: matrix.target == 'x86_64-unknown-linux-gnu' |
| 177 | + env: |
| 178 | + OUT_DIR: target/${{ matrix.target }}/${{ env.PROFILE }} |
| 179 | + VERSION_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }} |
| 180 | + shell: bash |
| 181 | + run: | |
| 182 | + sudo apt-get -y install help2man |
| 183 | + help2man -N $OUT_DIR/forge > forge.1 |
| 184 | + help2man -N $OUT_DIR/cast > cast.1 |
| 185 | + gzip forge.1 |
| 186 | + gzip cast.1 |
| 187 | + tar -czvf "foundry_man_${VERSION_NAME}.tar.gz" forge.1.gz cast.1.gz |
| 188 | + echo "foundry_man=foundry_man_${VERSION_NAME}.tar.gz" >> $GITHUB_OUTPUT |
| 189 | +
|
| 190 | + # Creates the release for this specific version |
| 191 | + - name: Create release |
| 192 | + uses: softprops/action-gh-release@v2 |
| 193 | + with: |
| 194 | + name: ${{ needs.prepare.outputs.release_name }} |
| 195 | + tag_name: ${{ needs.prepare.outputs.tag_name }} |
| 196 | + prerelease: ${{ env.IS_NIGHTLY == 'true' }} |
| 197 | + body: ${{ needs.prepare.outputs.changelog }} |
| 198 | + files: | |
| 199 | + ${{ steps.artifacts.outputs.file_name }} |
| 200 | + ${{ steps.man.outputs.foundry_man }} |
| 201 | +
|
| 202 | + - name: Binaries attestation |
| 203 | + uses: actions/attest-build-provenance@v2 |
| 204 | + with: |
| 205 | + subject-path: | |
| 206 | + ${{ env.cast_bin_path }} |
| 207 | + ${{ env.forge_bin_path }} |
| 208 | +
|
| 209 | + # If this is a nightly release, it also updates the release |
| 210 | + # tagged `nightly` for compatibility with `foundryup` |
| 211 | + - name: Update nightly release |
| 212 | + if: ${{ env.IS_NIGHTLY == 'true' }} |
| 213 | + uses: softprops/action-gh-release@v2 |
| 214 | + with: |
| 215 | + name: "Nightly" |
| 216 | + tag_name: "nightly" |
| 217 | + prerelease: true |
| 218 | + body: ${{ needs.prepare.outputs.changelog }} |
| 219 | + files: | |
| 220 | + ${{ steps.artifacts.outputs.file_name }} |
| 221 | + ${{ steps.man.outputs.foundry_man }} |
| 222 | +
|
| 223 | + cleanup: |
| 224 | + name: Release cleanup |
| 225 | + runs-on: ubuntu-latest |
| 226 | + timeout-minutes: 30 |
| 227 | + needs: release |
| 228 | + if: always() |
| 229 | + steps: |
| 230 | + - uses: actions/checkout@v4 |
| 231 | + |
| 232 | + # Moves the `nightly` tag to `HEAD` |
| 233 | + - name: Move nightly tag |
| 234 | + if: ${{ env.IS_NIGHTLY == 'true' }} |
| 235 | + uses: actions/github-script@v7 |
| 236 | + with: |
| 237 | + script: | |
| 238 | + const moveTag = require('./.github/scripts/move-tag.js') |
| 239 | + await moveTag({ github, context }, 'nightly') |
| 240 | +
|
| 241 | + - name: Delete old nightlies |
| 242 | + uses: actions/github-script@v7 |
| 243 | + with: |
| 244 | + script: | |
| 245 | + const prunePrereleases = require('./.github/scripts/prune-prereleases.js') |
| 246 | + await prunePrereleases({github, context}) |
| 247 | +
|
| 248 | + # If any of the jobs fail, this will create a high-priority issue to signal so. |
| 249 | + issue: |
| 250 | + name: Open an issue |
| 251 | + runs-on: ubuntu-latest |
| 252 | + needs: [ prepare, release, cleanup ] |
| 253 | + if: failure() |
| 254 | + steps: |
| 255 | + - uses: actions/checkout@v4 |
| 256 | + - uses: JasonEtco/create-an-issue@v2 |
| 257 | + env: |
| 258 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 259 | + WORKFLOW_URL: | |
| 260 | + ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 261 | + with: |
| 262 | + update_existing: true |
| 263 | + filename: .github/RELEASE_FAILURE_ISSUE_TEMPLATE.md |
0 commit comments