-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow for automatically generating release (#926)
* Add workflow for automatically generating release * Avoid script injection in workflow * Use correct secret
- Loading branch information
Showing
1 changed file
with
94 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: make-release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
target_branch: | ||
description: >- | ||
JSON array of branches to target. The first branch in the array will | ||
be marked as the latest release. | ||
required: false | ||
type: string | ||
default: '["main","release/0.15","release/0.12"]' | ||
|
||
jobs: | ||
bump-version: | ||
strategy: | ||
matrix: | ||
target_branch: ${{ fromJSON(inputs.target_branch) }} | ||
runs-on: ubuntu-latest | ||
env: | ||
CARGO_EDIT_VERSION: 0.12.2 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: '${{ matrix.target_branch }}' | ||
token: '${{ secrets.DIVVIUP_GITHUB_AUTOMATION_RELEASE_PAT }}' | ||
|
||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: Cache cargo edit | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ runner.tool_cache }}/cargo-edit | ||
key: cargo-edit-${{ env.CARGO_EDIT_VERSION }} | ||
- name: Add the tool cache directory to the search path | ||
run: echo "${{ runner.tool_cache }}/cargo-edit/bin/" >>$GITHUB_PATH | ||
- name: Ensure cargo-edit is installed | ||
run: | | ||
cargo install \ | ||
--root ${{ runner.tool_cache }}/cargo-edit \ | ||
--version ${{ env.CARGO_EDIT_VERSION }} \ | ||
cargo-edit | ||
- run: cargo set-version --package prio --bump patch | ||
- run: git diff | ||
- name: Push changes | ||
env: | ||
ACTOR: '${{ github.actor }}' | ||
run: | | ||
git config user.email "divviup-github-automation@divviup.org" | ||
git config user.name "divviup-github-automation" | ||
git commit -am "Bump libprio-rs patch version, triggered by @$ACTOR" | ||
git push | ||
# This job is kept separate from the previous one to enable retrying it without | ||
# bumping the version number again. | ||
make-release: | ||
strategy: | ||
matrix: | ||
target_branch: ${{ fromJSON(inputs.target_branch) }} | ||
runs-on: ubuntu-latest | ||
needs: [bump-version] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: '${{ matrix.target_branch }}' | ||
token: '${{ secrets.DIVVIUP_GITHUB_AUTOMATION_RELEASE_PAT }}' | ||
|
||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: stable | ||
|
||
- name: Create release | ||
env: | ||
GH_TOKEN: '${{ secrets.DIVVIUP_GITHUB_AUTOMATION_RELEASE_PAT }}' | ||
TARGET_BRANCH: '${{ matrix.target_branch }}' | ||
FIRST_BRANCH: '${{ fromJSON(inputs.target_branch)[0] }}' | ||
run: | | ||
# Determine the workspace version. | ||
VERSION=$(cargo metadata --no-deps | jq -er '.packages[0].version') | ||
LATEST= | ||
if [ "$TARGET_BRANCH" == "$FIRST_BRANCH" ]; then | ||
LATEST="--latest=true" | ||
else | ||
LATEST="--latest=false" | ||
fi | ||
gh release create "$VERSION" \ | ||
--generate-notes \ | ||
--target "$TARGET_BRANCH" \ | ||
$LATEST |