Skip to content

Commit

Permalink
ci: automate creation of GitHub releases and tags (#475)
Browse files Browse the repository at this point in the history
* ci: automate creation of GitHub releases and tags

* Added readme update

* ci: publish assets to draft github releases

* docs: document the new release process and possible improvements

* chore: apply suggestions from code review

Co-authored-by: Steve Loeppky <[email protected]>

* Update RELEASE.md

* Update RELEASE.md

---------

Co-authored-by: Steve Loeppky <[email protected]>
  • Loading branch information
galargh and BigLep authored Aug 19, 2024
1 parent affaf21 commit a6368b9
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 127 deletions.
68 changes: 1 addition & 67 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
push:
branches:
- master
tags:
- v*
workflow_dispatch:
inputs:
save:
Expand Down Expand Up @@ -115,7 +113,7 @@ jobs:
cd $(mktemp -d)
go install github.com/filecoin-project/go-paramfetch/paramfetch@latest
$GOPATH/bin/paramfetch 2048 "${DIR}/parameters.json" "${DIR}/srs-inner-product.json"
- if: runner.os == 'Linux' && ((github.event == 'push' && !startsWith(github.ref, 'refs/tags/')) || github.event.inputs.save == 'true')
- if: runner.os == 'Linux' && (github.event == 'push' || github.event.inputs.save == 'true')
uses: actions/cache/save@v3
with:
key: v28-proof-params-${{ runner.os }}-${{ runner.arch }}
Expand Down Expand Up @@ -147,67 +145,3 @@ jobs:
ref: ${{ github.event.inputs.ref }}
- name: Build project with `FFI_USE_CUDA_SUPRASEAL=1`
run: FFI_BUILD_FROM_SOURCE=1 FFI_USE_CUDA_SUPRASEAL=1 make
publish:
needs: [check, cgo-bindings, supraseal]
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event.inputs.publish == 'true'
name: Publish the static library (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: ['ubuntu-latest', ['self-hosted', 'linux', 'arm64', 'xlarge'], 'macos-latest']
fail-fast: false
steps:
- run: echo "Running on $RUNNER_OS $RUNNER_ARCH"
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: ./.github/actions/configure-environment
- if: github.event.inputs.ref != ''
uses: actions/checkout@v4
with:
submodules: recursive
ref: ${{ github.event.inputs.ref }}
- if: runner.os == 'macOS'
run: |
cd rust && rustup target add x86_64-apple-darwin
cd rust && cargo fetch
- if: runner.os == 'Linux'
name: Build and publish the standard release
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
TARBALL_PATH="/tmp/${REPOSITORY_NAME}-$(uname)-$(uname -m)-standard.tar.gz"
RELEASE_NAME="${REPOSITORY_NAME}-$(uname)-$(uname -m)-standard"
# Note: the blst dependency uses the portable configuration for maximum compatibility
./scripts/build-release.sh build --verbose --no-default-features --features multicore-sdr,opencl,blst-portable
./scripts/package-release.sh $TARBALL_PATH
./scripts/publish-release.sh $TARBALL_PATH $RELEASE_NAME
- if: runner.os == 'Linux'
name: Build the optimized release
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
TARBALL_PATH="/tmp/${CIRCLE_PROJECT_REPONAME}-$(uname)-$(uname -m)-optimized.tar.gz"
RUSTFLAGS="-C target-feature=$(cat rustc-target-features-optimized.json | jq -r '.[].rustc_target_feature' | tr '\n' ',')"
./scripts/build-release.sh build --verbose --no-default-features --features multicore-sdr,opencl
./scripts/package-release.sh $TARBALL_PATH
- if: runner.os == 'macOS'
name: Build and publish the universal standard release
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
RELEASE_NAME="${CIRCLE_PROJECT_REPONAME}-$(uname)-standard"
TARBALL_PATH="/tmp/${RELEASE_NAME}.tar.gz"
# Note: the blst dependency uses the portable configuration for maximum compatibility
./scripts/build-release.sh lipo --verbose --no-default-features --features multicore-sdr,opencl,blst-portable
./scripts/package-release.sh $TARBALL_PATH
./scripts/publish-release.sh $TARBALL_PATH $RELEASE_NAME
84 changes: 84 additions & 0 deletions .github/workflows/release-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Release Checker

on:
pull_request_target:
paths: ["version.json"]
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/[email protected]
with:
sources: '["version.json"]'
upload-release-assets:
needs: [release-check]
if: fromJSON(needs.release-check.outputs.json)['version.json']
name: Publish the static library (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: ['ubuntu-latest', ['self-hosted', 'linux', 'arm64', 'xlarge'], 'macos-latest']
fail-fast: false
steps:
- run: echo "Running on $RUNNER_OS $RUNNER_ARCH"
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: ./.github/actions/configure-environment
- if: runner.os == 'macOS'
run: |
cd rust && rustup target add x86_64-apple-darwin
cd rust && cargo fetch
- if: runner.os == 'Linux'
name: Build and publish the standard release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
TARBALL_PATH="/tmp/${REPOSITORY_NAME}-$(uname)-$(uname -m)-standard.tar.gz"
RELEASE_NAME="${REPOSITORY_NAME}-$(uname)-$(uname -m)-standard"
# Note: the blst dependency uses the portable configuration for maximum compatibility
./scripts/build-release.sh build --verbose --no-default-features --features multicore-sdr,opencl,blst-portable
./scripts/package-release.sh $TARBALL_PATH
./scripts/publish-release.sh $TARBALL_PATH $RELEASE_NAME
- if: runner.os == 'Linux'
name: Build the optimized release
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
TARBALL_PATH="/tmp/${REPOSITORY_NAME}-$(uname)-$(uname -m)-optimized.tar.gz"
RUSTFLAGS="-C target-feature=$(cat rustc-target-features-optimized.json | jq -r '.[].rustc_target_feature' | tr '\n' ',')"
./scripts/build-release.sh build --verbose --no-default-features --features multicore-sdr,opencl
./scripts/package-release.sh $TARBALL_PATH
- if: runner.os == 'macOS'
name: Build and publish the universal standard release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
RELEASE_NAME="${REPOSITORY_NAME}-$(uname)-standard"
TARBALL_PATH="/tmp/${RELEASE_NAME}.tar.gz"
# Note: the blst dependency uses the portable configuration for maximum compatibility
./scripts/build-release.sh lipo --verbose --no-default-features --features multicore-sdr,opencl,blst-portable
./scripts/package-release.sh $TARBALL_PATH
./scripts/publish-release.sh $TARBALL_PATH $RELEASE_NAME
21 changes: 21 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Releaser

on:
push:
paths: ["version.json"]
workflow_dispatch:

permissions:
contents: write

concurrency:
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true

jobs:
releaser:
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
with:
sources: '["version.json"]'
secrets:
UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }}
38 changes: 3 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Run it like so:
./mkreleaselog v0.25.0 v0.26.0 > /tmp/v0.26.0.notes.txt
```

## Contribution
## Contribution

### Maintainers

Expand Down Expand Up @@ -124,47 +124,15 @@ We will cooperates with the [lotus' releases and it's testing flows](https://git
- If any bug is found during the testing, the fix should land in master then get backported to `release/lotus-vX`. The updated commit should be integrated into lotus and getting tested. Repeat the steps until it can be considered as stable.

*Consensus breaking changes*
- Consensus breaking changes should be developed in it's own branch, (branch name is suggested to be: feature branches `feat/` or bug fix branches `bug/`).
- Consensus breaking changes should be developed in it's own branch, (branch name is suggested to be: feature branches `feat/` or bug fix branches `bug/`).
- Consensus breaking changes that are scoped into the next immediate network upgrade shall land in `next` branch first. The maintainers are responsible to coordinate on when to land `next` to `master` according to lotus mandatory(network upgrade) release schedules.
- A new dev branch should be created and contributors are responsible to rebase the branch onto `master`/`next` as needed.

#### Versioning

The versioning in Filecoin-FFI currently follows the Lotus versioning. For example, if you are cutting a release for Lotus v1.28.0-rc1, the Filecoin-FFI release will be named v1.28.0-rc1 as well. (Note: Lotus versioning will be refactored in the near future as part of [lotus #12072](https://github.com/filecoin-project/lotus/issues/12072).)

#### Release Process

##### Cutting a development or release candidate release

<details>
<summary>Steps to cut a development or release candidate release:</summary>

1. Go to [Filecoin-FFI Releases](https://github.com/filecoin-project/filecoin-ffi/releases).
2. Click the "Draft a new release" button in the right corner.
3. In the "Choose a tag" dropdown, enter the desired version and click "Create new tag: vX.XX.X-rcX/dev on publish".
4. Target the master branch.
5. Set the previous tag to compare against, which should be the last stable release.
6. Click the "Generate release notes" button.
6. Check the "Set as a pre-release" checkbox.
7. Click "Publish release" to create the release.

</details>

##### Cutting a definitive release

<details>
<summary>Steps to cut a definitive release:</summary>

1. Go to [Filecoin-FFI Releases](https://github.com/filecoin-project/filecoin-ffi/releases).
2. Click the "Draft a new release" button in the right corner.
3. In the "Choose a tag" dropdown, enter the desired version and click "Create new tag: vX.XX.X on publish".
4. Target the release candidate you want to create a stable.
5. Set the previous tag to compare against, which should be the last stable release (e.g., non-RC)
6. click the "Generate release notes" button.
6. Ensure the "Set as a latest release" checkbox **is checked**.
7. Click "Publish release" to create the release.

</details>
#### [Release Process](RELEASE.md)

## License

Expand Down
28 changes: 28 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Release Process

This document describes the process for releasing a new version of the `filecoin-ffi` project.

## Current State

1. Create a pull request which updates the `version` in the [top-level `version.json` file](https://github.com/filecoin-project/filecoin-ffi/blob/master/version.json).
- Title the PR `chore: X.Y.Z release`
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 `version.json` 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. (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 the project for Linux (X64), Linux (ARM64), and MacOS.
7. Upload the built 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 `version.json` 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 and publish a new release with the version as the git tag. Publishing the release creates the git tag.

## Known Limitations

1. If one pushes an update to the `version` in the top-level `version.json` 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 [publish-release.sh](rust/scripts/publish-release.sh) script to upload the missing assets.
50 changes: 25 additions & 25 deletions rust/scripts/publish-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,46 @@ main() {
fi

local __release_file=$1
local __release_name=$2
local __release_tag="${CIRCLE_SHA1:0:16}"
local __release_url="${GITHUB_RELEASE_URL}"
local __release_target="$(basename $__release_file)"

# make sure we have a token set, api requests won't work otherwise
if [ -z $GITHUB_TOKEN ]; then
(>&2 echo "[publish-release/main] \$GITHUB_TOKEN not set, publish failed")
exit 1
fi

# make sure we have a release url set
if [ -z "$GITHUB_RELEASE_URL" ]; then
(>&2 echo "[publish-release/main] \$GITHUB_RELEASE_URL not set, publish failed")
exit 1
fi

# see if the release already exists by tag
local __release_response=`
curl \
--header "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases/tags/$__release_tag"
"$__release_url"
`

local __release_id=`echo $__release_response | jq '.id'`

if [ "$__release_id" = "null" ]; then
(>&2 echo '[publish-release/main] creating release')

RELEASE_DATA="{
\"tag_name\": \"$__release_tag\",
\"target_commitish\": \"$CIRCLE_SHA1\",
\"name\": \"$__release_tag\",
\"body\": \"\"
}"

# create it if it doesn't exist yet
#
__release_response=`
curl \
--request POST \
--header "Authorization: token $GITHUB_TOKEN" \
--header "Content-Type: application/json" \
--data "$RELEASE_DATA" \
"https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases"
`
else
(>&2 echo '[publish-release/main] release already exists')
(>&2 echo '[publish-release/main] release does not exist')
exit 1
fi

__release_target_asset=`echo $__release_response | jq -r ".assets | .[] | select(.name == \"$release_target\")"`

if [ -n "$__release_target_asset" ]; then
(>&2 echo "[publish-release/main] $__release_target_asset already exists, deleting")

__release_target_asset_url=`echo $__release_target_asset | jq -r '.url'`

curl \
--request DELETE \
--header "Authorization: token $GITHUB_TOKEN" \
"$__release_target_asset_url"
fi

__release_upload_url=`echo $__release_response | jq -r '.upload_url' | cut -d'{' -f1`
Expand All @@ -65,7 +65,7 @@ main() {
--header "Authorization: token $GITHUB_TOKEN" \
--header "Content-Type: application/octet-stream" \
--data-binary "@$__release_file" \
"$__release_upload_url?name=$(basename $__release_file)"
"$__release_upload_url?name=$__release_target"

(>&2 echo '[publish-release/main] release file uploaded')
}
Expand Down
3 changes: 3 additions & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "v1.28.0"
}

0 comments on commit a6368b9

Please sign in to comment.