Add promote workflow

This commit is contained in:
Jonathan Kelley 2024-02-21 22:08:01 -08:00
parent 319eb29ff4
commit 6cc66b5d11
No known key found for this signature in database
GPG key ID: 1FBB50F7EB0A08BE
2 changed files with 53 additions and 13 deletions

View file

@ -1,4 +1,46 @@
# promote nightly to stable
# Create a PR that promotes the current main pre-release to the next stable release
#
# runs the various git commands to update the version
# should be followed up by a stable release
# IE if the current master version is 0.4.0-rc.7, this will create a PR to promote it to 0.4.0
#
# - update the version in the Cargo.toml to v0.4.0
# - generate a v0.4 branch
# - push the branch to the repository
# - then bump 0.4.0-rc.1 to 0.5.0-rc.0
#
# This means main will never be a "stable" release, and we can always merge breaking changes to main
# and backport them to the latest stable release
#
# This is configured to be ran manually, but could honestly just be a release workflow
on:
workflow_dispatch:
permissions:
actions: write
jobs:
promote:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Publish the next pre-release
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# go from eg 0.4.0-rc.7 to 0.4.0, committing the change
cargo workspaces version -y minor
# create a new branch for the release
RELEASE_BRANCH=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
RELEASE_BRANCH=v$(echo $RELEASE_BRANCH | sed 's/\.[0-9]*$//')
git branch $RELEASE_BRANCH
# go from 0.4.0 to 0.5.0-rc.0
cargo workspaces version -y preminor --pre-id rc
# push the new branch to the repository
git push origin $RELEASE_BRANCH
# push the new version to the repository
git push origin main

View file

@ -21,24 +21,22 @@ on:
type: choice
description: "Branch to publish"
required: true
description: Choose the branch to publish. If the branch is main, it will publish a patch prerelease.
description: Choose the branch to publish.
options:
- main
- v0.4.x
- v0.5.x
- v0.6.x
# todo: more stable releases as time goes on
- v0.4
- v0.5
- v0.6
env:
# make sure we have the right semver.
# make sure we have the right version
# main is always a prepatch until we hit 1.0, and then this script needs to be updated
# note that we need to promote the prepatch to a minor bump when we actually do a release
# this means the version in git will always be one minor bump ahead of the actual release - basically meaning once
# we release a version, it's fair game to merge breaking changes to main since all semver-compatible changes will be
# backported automatically
SEMVER: ${{ github.event.inputs.channel == 'main' && 'prepatch' || 'patch' }}
PRERELEASE_TAG: ${{ github.event.inputs.channel == 'main' && '-prerelease' || '' }}
SEMVER: ${{ github.event.inputs.channel == 'main' && 'prerelease' || 'patch' }}
PRERELEASE_TAG: ${{ github.event.inputs.channel == 'main' && '-pre' || '' }}
jobs:
# First, run checks (clippy, tests, etc) and then publish the crates to crates.io
@ -77,7 +75,7 @@ jobs:
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
cargo workspaces version -y ${{ env.SEMVER }} --no-git-commit
cargo workspaces version -y ${{ env.SEMVER }} --pre-id rc --no-git-commit
# todo: actually just publish!
# cargo workspaces publish -y ${{ github.event.inputs.semver }}