From 656c14ec9e416c14fc9b9b158a6bc9a840114219 Mon Sep 17 00:00:00 2001 From: galargh Date: Tue, 23 Jul 2024 14:20:46 +0100 Subject: [PATCH 1/8] ci: automate creation of GitHub releases and tags --- .github/workflows/release-check.yml | 21 +++++++++++++++++++++ .github/workflows/releaser.yml | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .github/workflows/release-check.yml create mode 100644 .github/workflows/releaser.yml diff --git a/.github/workflows/release-check.yml b/.github/workflows/release-check.yml new file mode 100644 index 000000000..6e29d7ad5 --- /dev/null +++ b/.github/workflows/release-check.yml @@ -0,0 +1,21 @@ +name: Release Checker + +on: + pull_request_target: + paths: ["Cargo.toml"] + types: [ opened, synchronize, reopened, labeled, unlabeled ] + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + release-check: + uses: ipdxco/unified-github-workflows/.github/workflows/release-check.yml@v1.0 + with: + sources: '["Cargo.toml"]' diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml new file mode 100644 index 000000000..a95658ea4 --- /dev/null +++ b/.github/workflows/releaser.yml @@ -0,0 +1,21 @@ +name: Releaser + +on: + push: + paths: ["Cargo.toml"] + workflow_dispatch: + +permissions: + contents: write + +concurrency: + group: ${{ github.workflow }}-${{ github.sha }} + cancel-in-progress: true + +jobs: + releaser: + uses: ipdxco/unified-github-workflows/.github/workflows/releaser.yml@v1.0 + with: + sources: '["Cargo.toml"]' + secrets: + UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }} From 3b0c3e7a0027457d3941839651aa9bcc2f1aa79f Mon Sep 17 00:00:00 2001 From: galargh Date: Tue, 23 Jul 2024 14:28:44 +0100 Subject: [PATCH 2/8] docs: update documentation on release creation --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index bd65a6e09..5f77fa068 100644 --- a/README.md +++ b/README.md @@ -87,9 +87,8 @@ Precompiled actor bundles are provided as [release binaries][releases] in this r We release all actors, the runtime, and the state abstraction at the same time by: 1. Changing the `workspace.package.version` in the top-level `Cargo.toml` file. -2. Creating a [release][releases] in GitHub. -This will trigger an automatic bundle-build by GitHub CI, and the generated bundles will be attached to the GitHub release. +This will trigger an automatic GitHub release and associated tags creation and then it will also trigger bundle-build by GitHub CI, and the generated bundles will be attached to the GitHub release. ## Instructions for client implementations From fc7fce7a5c693c173c806ec21dcaf08d5ebf4886 Mon Sep 17 00:00:00 2001 From: galargh Date: Thu, 25 Jul 2024 15:10:13 +0100 Subject: [PATCH 3/8] ci: upload release assets to the draft --- .github/workflows/release-check.yml | 33 +++++++++++++++ .github/workflows/release.yml | 40 ------------------- ...sh-release.sh => upload-release-assets.sh} | 34 ++++++++++++---- 3 files changed, 60 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/release.yml rename scripts/{publish-release.sh => upload-release-assets.sh} (60%) diff --git a/.github/workflows/release-check.yml b/.github/workflows/release-check.yml index 6e29d7ad5..11d17f144 100644 --- a/.github/workflows/release-check.yml +++ b/.github/workflows/release-check.yml @@ -19,3 +19,36 @@ jobs: uses: ipdxco/unified-github-workflows/.github/workflows/release-check.yml@v1.0 with: sources: '["Cargo.toml"]' + upload-release-assets: + needs: [release-check] + if: fromJSON(needs.release-check.outputs.json)['Cargo.toml'] + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_INCREMENTAL: 0 + CACHE_SKIP_SAVE: ${{ matrix.push == '' || matrix.push == 'false' }} + RUSTFLAGS: -Dwarnings + strategy: + matrix: + network: [ 'mainnet', 'caterpillarnet', 'butterflynet', 'calibrationnet', 'devnet', 'testing', 'testing-fake-proofs' ] + steps: + - name: Checking out + uses: actions/checkout@v4 + - name: Setting up cache + uses: pl-strflt/rust-sccache-action@v1 + env: + SCCACHE_CACHE_SIZE: 2G + SCCACHE_DIR: ${{ github.workspace }}/.cache/sccache + CACHE_SKIP_SAVE: true + - name: Writing bundle + env: + BUILD_FIL_NETWORK: ${{ matrix.network }} + run: | + cargo run --locked -- -o output/builtin-actors.car + - name: Upload release assets to GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_RELEASE_URL: ${{ fromJSON(needs.release-check.outputs.json)['Cargo.toml'].url }} + BUILD_FIL_NETWORK: ${{ matrix.network }} + run: | + ./scripts/upload-release-assets.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index f50228eae..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Release - -on: - release: - types: [published] - -env: - RUSTFLAGS: -Dwarnings - -jobs: - release: - runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CARGO_INCREMENTAL: 0 - CACHE_SKIP_SAVE: ${{ matrix.push == '' || matrix.push == 'false' }} - strategy: - matrix: - network: [ 'mainnet', 'caterpillarnet', 'butterflynet', 'calibrationnet', 'devnet', 'testing', 'testing-fake-proofs' ] - steps: - - name: Checking out - uses: actions/checkout@v3 - - name: Setting up cache - uses: pl-strflt/rust-sccache-action@v1 - env: - SCCACHE_CACHE_SIZE: 2G - SCCACHE_DIR: ${{ github.workspace }}/.cache/sccache - CACHE_SKIP_SAVE: true - - name: Writing bundle - env: - BUILD_FIL_NETWORK: ${{ matrix.network }} - run: | - cargo run --locked -- -o output/builtin-actors.car - - name: Publishing release and uploading bundle to GitHub - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_REF: ${{ github.ref }} - BUILD_FIL_NETWORK: ${{ matrix.network }} - run: | - ./scripts/publish-release.sh diff --git a/scripts/publish-release.sh b/scripts/upload-release-assets.sh similarity index 60% rename from scripts/publish-release.sh rename to scripts/upload-release-assets.sh index 12f6a633a..58c636f40 100755 --- a/scripts/publish-release.sh +++ b/scripts/upload-release-assets.sh @@ -12,9 +12,9 @@ if [ -z "$GITHUB_TOKEN" ]; then die "no GITHUB_TOKEN" fi -# make sure we have a release tag set -if [ -z "$GITHUB_REF" ]; then - die "no GITHUB_REF" +# make sure we have a release url set +if [ -z "$GITHUB_RELEASE_URL" ]; then + die "no GITHUB_RELEASE_URL" fi # make sure we have a target set @@ -28,8 +28,6 @@ release_target=builtin-actors-${BUILD_FIL_NETWORK}.car release_target_hash=builtin-actors-${BUILD_FIL_NETWORK}.sha256 release_file=output/$release_target release_file_hash=output/$release_target_hash -# the ref is of the form refs/tags/; drop the prefix to get the actual release tag -release_tag="${GITHUB_REF:10}" # prepare artifacts pushd output @@ -45,16 +43,27 @@ REPO="builtin-actors" __release_response=` curl \ --header "Authorization: token $GITHUB_TOKEN" \ - "https://api.github.com/repos/$ORG/$REPO/releases/tags/$release_tag" + "$GITHUB_RELEASE_URL" ` __release_id=`echo $__release_response | jq '.id'` if [ "$__release_id" = "null" ]; then - echo "release $release_tag does not exist" + echo "release does not exist" exit 1 fi __release_upload_url=`echo $__release_response | jq -r '.upload_url' | cut -d'{' -f1` +__release_target_asset=`echo $__release_response | jq -r ".assets | .[] | select(.name == \"$release_target\")"` + +if [ -n "$__release_target_asset" ]; then + echo "deleting $release_target" + __release_target_asset_url=`echo $__release_target_asset | jq -r '.url'` + curl \ + --request DELETE \ + --header "Authorization: token $GITHUB_TOKEN" \ + "$__release_target_asset_url" +fi + echo "uploading $release_target" curl \ --request POST \ @@ -63,6 +72,17 @@ curl \ --data-binary "@$release_file" \ "$__release_upload_url?name=$release_target" +__release_target_hash_asset=`echo $__release_response | jq -r ".assets | .[] | select(.name == \"$release_target_hash\")"` + +if [ -n "$__release_target_hash_asset" ]; then + echo "deleting $release_target_hash" + __release_target_hash_asset_url=`echo $__release_target_hash_asset | jq -r '.url'` + curl \ + --request DELETE \ + --header "Authorization: token $GITHUB_TOKEN" \ + "$__release_target_hash_asset_url" +fi + echo "uploading $release_target_hash" curl \ --request POST \ From 2d3ead84efe47f6ae84b5ae3ee9fe014c3389f15 Mon Sep 17 00:00:00 2001 From: Piotr Galar Date: Mon, 5 Aug 2024 21:21:01 +0200 Subject: [PATCH 4/8] chore: apply suggestions from code review Co-authored-by: Steve Loeppky --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f77fa068..d72971a42 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ We release all actors, the runtime, and the state abstraction at the same time b 1. Changing the `workspace.package.version` in the top-level `Cargo.toml` file. -This will trigger an automatic GitHub release and associated tags creation and then it will also trigger bundle-build by GitHub CI, and the generated bundles will be attached to the GitHub release. +This triggers CI to create a draft GitHub Release, create the associated tags, and built and upload assets to the release. When the PR is merged, the GitHub Release will be published. ## Instructions for client implementations From cf0b50869fe3a82228d54d1ca48702f7f7787917 Mon Sep 17 00:00:00 2001 From: Piotr Galar Date: Mon, 5 Aug 2024 21:22:09 +0200 Subject: [PATCH 5/8] chore: apply suggestions from code review Co-authored-by: Steve Loeppky --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d72971a42..85f744c50 100644 --- a/README.md +++ b/README.md @@ -84,9 +84,7 @@ Precompiled actor bundles are provided as [release binaries][releases] in this r ## Releasing -We release all actors, the runtime, and the state abstraction at the same time by: - -1. Changing the `workspace.package.version` in the top-level `Cargo.toml` file. +We release all actors, the runtime, and the state abstraction at the same time by opening a PR changing the `workspace.package.version` in the top-level `Cargo.toml` file. This triggers CI to create a draft GitHub Release, create the associated tags, and built and upload assets to the release. When the PR is merged, the GitHub Release will be published. From 562eee7457c838b3a14f42bf73ddf11d9a603508 Mon Sep 17 00:00:00 2001 From: galargh Date: Tue, 13 Aug 2024 14:02:56 +0200 Subject: [PATCH 6/8] docs: document the new release process and possible improvements --- README.md | 6 +----- RELEASE.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 RELEASE.md diff --git a/README.md b/README.md index 85f744c50..19af554a6 100644 --- a/README.md +++ b/README.md @@ -82,11 +82,7 @@ Precompiled actor bundles are provided as [release binaries][releases] in this r [`fil_builtin_actors_bundle`](https://crates.io/crates/fil_builtin_actors_bundle) crate on [crates.io](https://crates.io) will not be updated. -## Releasing - -We release all actors, the runtime, and the state abstraction at the same time by opening a PR changing the `workspace.package.version` in the top-level `Cargo.toml` file. - -This triggers CI to create a draft GitHub Release, create the associated tags, and built and upload assets to the release. When the PR is merged, the GitHub Release will be published. +## [Releasing](RELEASE.md) ## Instructions for client implementations diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 000000000..4e9a9e3c5 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,28 @@ +# Release Process + +This document describes the process for releasing a new version of the `builtin-actors` project. + +## Current State + +1. Create a pull request which updates the `workspace.package.version` in the top-level `Cargo.toml` file. +2. On pull request creation, a [Release Checker](.github/workflows/release-check.yml) workflow will run. It will perform the following actions: + 1. Extract the version from the top-level `Cargo.toml` file. + 2. Check if a git tag for the version already exists. Continue only if it does not. + 3. Create a draft GitHub release with the version as the tag. + 4. Comment on the pull request with a link to the draft release. + 5. Build `builtin-actors.car`s for various networks. + 6. Generate checksums for the built `builtin-actors.car`s. + 7. Upload the built `builtin-actors.car`s and checksums as assets to the draft release (replace any existing assets with the same name). +3. On pull request merge, a [Releaser](.github/workflows/release.yml) workflow will run. It will perform the following actions: + 1. Extract the version from the top-level `Cargo.toml` file. + 2. Check if a git tag for the version already exists. Continue only if it does not. + 3. Check if a draft GitHub release with the version as the tag exists. + 4. If the draft release exists, publish it. Otherwise, create a new release with the version as the tag. + +## Known Limitations + +1. If one pushes an update to the `workspace.package.version` in the top-level `Cargo.toml` file without creating a pull request, the Release Checker workflow will not run. Hence, the release assets will not be automatically built and uploaded. + +## Possible Improvements + +1. Add a check to the [Releaser](.github/workflows/release.yml) workflow to ensure that the created/published release contains the expected assets. If it does not, create them and run the [upload-release-assets.sh](scripts/upload-release-assets.sh) script to upload the missing assets. From 5cda5b9cd8b5043d1e2c5daf90b3c2d0e2fae5a2 Mon Sep 17 00:00:00 2001 From: Piotr Galar Date: Wed, 14 Aug 2024 10:13:37 +0200 Subject: [PATCH 7/8] chore: apply suggestions from code review Co-authored-by: Steve Loeppky --- RELEASE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 4e9a9e3c5..51fa50579 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -4,7 +4,8 @@ This document describes the process for releasing a new version of the `builtin- ## Current State -1. Create a pull request which updates the `workspace.package.version` in the top-level `Cargo.toml` file. +1. Create a pull request which updates the `workspace.package.version` in the [top-level `Cargo.toml` file](https://github.com/filecoin-project/builtin-actors/blob/master/Cargo.toml). + - Title the PR `chore: release X.Y.Z` 2. On pull request creation, a [Release Checker](.github/workflows/release-check.yml) workflow will run. It will perform the following actions: 1. Extract the version from the top-level `Cargo.toml` file. 2. Check if a git tag for the version already exists. Continue only if it does not. From ffda880a948a0b9f6c71e89c9c0976f70d2f949c Mon Sep 17 00:00:00 2001 From: Steve Loeppky Date: Wed, 14 Aug 2024 17:50:12 -0700 Subject: [PATCH 8/8] Apply suggestions from code review --- RELEASE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 51fa50579..0af761a59 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -9,7 +9,7 @@ This document describes the process for releasing a new version of the `builtin- 2. On pull request creation, a [Release Checker](.github/workflows/release-check.yml) workflow will run. It will perform the following actions: 1. Extract the version from the top-level `Cargo.toml` file. 2. Check if a git tag for the version already exists. Continue only if it does not. - 3. Create a draft GitHub release with the version as the tag. + 3. Create a draft GitHub release with the version as the tag. (A git tag with this version string will be created when the release is published.) 4. Comment on the pull request with a link to the draft release. 5. Build `builtin-actors.car`s for various networks. 6. Generate checksums for the built `builtin-actors.car`s. @@ -18,7 +18,7 @@ This document describes the process for releasing a new version of the `builtin- 1. Extract the version from the top-level `Cargo.toml` file. 2. Check if a git tag for the version already exists. Continue only if it does not. 3. Check if a draft GitHub release with the version as the tag exists. - 4. If the draft release exists, publish it. Otherwise, create a new release with the version as the tag. + 4. If the draft release exists, publish it. Otherwise, create and publish a new release with the version as the git tag. Publishing the release creates the git tag. ## Known Limitations