-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Nightly releases * Add manual workflow trigger * Use runner's `GITHUB_TOKEN` * Remove unneeded config - `name` defaults to `tag_name` - `GITHUB_TOKEN` is not used from environment * Cross-compile for M1 * Fix `IS_NIGHTLY` * Fix `--target` for `cargo` step * Disable M1 builds * Strip binaries for all platforms * Enable various release optimizations See https://github.com/johnthagen/min-sized-rust * Re-enable macOS and actually disable M1
- Loading branch information
Showing
2 changed files
with
83 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,104 @@ | ||
name: Release version | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
schedule: | ||
- cron: '0 0 * * *' | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'Tag name to release or nightly for nightly releases' | ||
required: true | ||
default: nightly | ||
|
||
env: | ||
TAG_NAME: ${{ (github.event_name == 'schedule' && 'nightly') || github.inputs.tag || github.ref_name }} | ||
IS_NIGHTLY: ${{ github.event_name != 'push' }} | ||
|
||
jobs: | ||
# this job builds the `forge` and `cast` binaries for the specified platforms | ||
# in the matrix. The MacOS binaries do not support M1 yet: https://github.com/actions/runner/issues/805 | ||
build-artifacts: | ||
runs-on: ${{ matrix.os }} | ||
release: | ||
name: ${{ matrix.job.target }} (${{ matrix.job.os }}) | ||
runs-on: ${{ matrix.job.os }} | ||
strategy: | ||
matrix: | ||
os: [macos-latest, ubuntu-latest] | ||
job: | ||
# The OS is used for the runner | ||
# The platform is a generic platform name | ||
# The target is used by Cargo | ||
# The arch is either 386 or amd64 | ||
- os: ubuntu-latest | ||
platform: linux | ||
target: x86_64-unknown-linux-gnu | ||
arch: amd64 | ||
- os: macos-latest | ||
platform: darwin | ||
target: x86_64-apple-darwin | ||
arch: amd64 | ||
# We can't compile for M1 yet | ||
# See https://github.com/rust-bitcoin/rust-secp256k1/issues/283 | ||
#- os: macos-latest | ||
# platform: darwin | ||
# target: aarch64-apple-darwin | ||
# arch: arm64 | ||
- os: windows-latest | ||
platform: win32 | ||
target: x86_64-pc-windows-msvc | ||
arch: amd64 | ||
|
||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
target: ${{ matrix.job.target }} | ||
override: true | ||
|
||
- uses: Swatinem/rust-cache@v1 | ||
with: | ||
cache-on-failure: true | ||
- name: cargo build | ||
|
||
- name: Build binaries | ||
env: | ||
RUSTFLAGS: -C link-args=-s | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --release | ||
|
||
- name: Upload production artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: target-${{ matrix.os }} | ||
path: | | ||
./target/release/forge | ||
./target/release/cast | ||
args: --release --bins --target ${{ matrix.job.target }} | ||
|
||
# creates a GH release with the built binaries and CHANGELOG entry | ||
create-release: | ||
runs-on: ubuntu-latest | ||
needs: build-artifacts | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1000 | ||
|
||
- name: Set output | ||
id: vars | ||
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} | ||
|
||
- name: Restore artifacts | ||
uses: actions/download-artifact@v2 | ||
|
||
- name: Build Changelog | ||
id: github_release | ||
uses: mikepenz/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
|
||
- name: Create Release | ||
id: create-release | ||
uses: softprops/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.vars.outputs.tag }} | ||
release_name: ${{ github.ref }} | ||
body: ${{steps.build_changelog.outputs.changelog}} | ||
files: | | ||
./target-macos-latest | ||
./target-ubuntu-latest | ||
- name: Archive binaries | ||
id: artifacts | ||
env: | ||
PLATFORM_NAME: ${{ matrix.job.platform }} | ||
ARCH: ${{ matrix.job.arch }} | ||
run: | | ||
if [ "$PLATFORM_NAME" != "win32" ]; then | ||
tar -czvf "foundry_${TAG_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/release forge cast | ||
echo "::set-output name=file_name::foundry_${TAG_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" | ||
else | ||
cd ./target/release | ||
7z a -tzip "foundry_${TAG_NAME}_${PLATFORM_NAME}_${ARCH}.zip" forge.exe cast.exe | ||
mv "foundry_${TAG_NAME}_${PLATFORM_NAME}_${ARCH}.zip" ../../ | ||
echo "::set-output name=file_name::foundry_${TAG_NAME}_${PLATFORM_NAME}_${ARCH}.zip" | ||
fi | ||
shell: bash | ||
|
||
- name: Build changelog | ||
id: build_changelog | ||
if: ${{ env.IS_NIGHTLY == false }} | ||
uses: mikepenz/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# after the GH release is done, proceed to open a PR on homebrew-core | ||
publish-homebrew: | ||
runs-on: ubuntu-latest | ||
needs: build-artifacts | ||
steps: | ||
- name: Create homebrew-core PR | ||
uses: mislav/[email protected] | ||
- name: Create release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
formula-name: foundry | ||
env: | ||
COMMITTER_TOKEN: ${{ secrets.GH_TOKEN }} | ||
tag_name: ${{ env.TAG_NAME }} | ||
draft: ${{ env.IS_NIGHTLY }} | ||
body: ${{ steps.build_changelog.outputs.changelog }} | ||
files: ${{ steps.artifacts.outputs.file_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters