Skip to content

Automated Release Process #8

Automated Release Process

Automated Release Process #8

# Initiation half of the release process for this repository.
#
# This is triggered manually through the github actions UI and will execute
# `./publish bump` (or `bump-patch`). Afterwards the result will be pushed to a
# branch in the main repository and a PR will be opened. This PR, when merged,
# will trigger the second half in `publish.yml`.
name: "Automated Release Process"
on:
# Allow manually triggering this request via the button on the action
# workflow page.
workflow_dispatch:
inputs:
action:
description: 'Publish script argument: "bump", or "bump-patch"'
required: false
default: 'bump'
jobs:
release_process:
name: Run the release process
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup
run: |
rustc ci/publish.rs
git config user.name 'Auto Release Process'
git config user.email 'auto-release-process@users.noreply.github.com'
git remote set-url origin https://git:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
- name: Bump version number
run: ./publish ${{ github.event.inputs.action }}
- name: Prep PR metadata
run: |
set -ex
git fetch origin
cur=$(./ci/print-current-version.sh)
git commit --allow-empty -a -F-<<EOF
Release ${{ github.event.repository.name }} $cur
[automatically-tag-and-release-this-commit]
EOF
# Push the result to a branch and setup metadata for the step below
# that creates a PR
git push origin HEAD:ci/release-$cur
echo "PR_HEAD=ci/release-$cur" >> $GITHUB_ENV
echo "PR_TITLE=Release ${{ github.event.repository.name }} $cur" >> $GITHUB_ENV
echo "PR_BASE=main" >> $GITHUB_ENV
cat > pr-body <<-EOF
This is an automated pull request from CI to release
${{ github.event.repository.name }} $cur when merged. The commit
message for this PR has a marker that is detected by CI to create
tags and publish crate artifacts.
When first opened this PR will not have CI run because it is generated
by a bot. A maintainer should close this PR and then reopen it to
trigger CI to execute which will then enable merging this PR.
EOF
- name: Make a PR
run: gh pr create -B "$PR_BASE" -H "$PR_HEAD" --title "$PR_TITLE" --body "$(cat ./pr-body)"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}