Skip to content

Draft new release

Draft new release #109

name: "Draft new release"
on:
workflow_dispatch:
inputs:
version:
description: "The new version in X.Y.Z format."
required: true
jobs:
draft-new-release:
name: "Draft a new release"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
RELEASE_BRANCH: release/${{ github.event.inputs.version }}
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_ACTION_TOKEN }}
- name: Create release branch
run: git checkout -b ${{ env.RELEASE_BRANCH }}
- name: Initialize mandatory git config
run: |
git config user.name "${{ secrets.GET10101_NAME }}"
git config user.email ${{ secrets.GET10101_EMAIL }}
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- uses: dprint/[email protected]
- name: Bump pubspec version
uses: fjogeleit/[email protected]
with:
valueFile: "mobile/pubspec.yaml"
propertyPath: "version"
value: ${{ github.event.inputs.version }}
commitChange: false
updateFile: true
- name: Install cargo edit
uses: stellar/binaries@v13
with:
name: cargo-edit
version: 0.11.6
- name: Bump coordinator Cargo.toml version
id: set-coordinator-version
continue-on-error: true
run: |
cargo set-version --package coordinator ${{ github.event.inputs.version }}
- name: Bump webapp Cargo.toml version
id: set-webapp-version
continue-on-error: true
run: |
cargo set-version --package webapp ${{ github.event.inputs.version }}
- name: Bump mobile/native Cargo.toml version
id: set-mobile-version
continue-on-error: true
run: |
cargo set-version --package native ${{ github.event.inputs.version }}
- name: Commit manifest files
id: make-commit
run: |
/home/runner/.dprint/bin/dprint fmt
git add mobile/native/Cargo.toml mobile/pubspec.yaml coordinator/Cargo.toml webapp/Cargo.toml Cargo.lock
git commit --message "Prepare release ${{ github.event.inputs.version }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Create pull request
run: |
# Force push to allow for easier re-runs of the action
git push origin ${{ env.RELEASE_BRANCH }} --force
# Use heredoc to define multiline string: https://stackoverflow.com/a/23930212/2489334
BODY=$(cat <<-EOF
Hi @${{ github.actor }}!
This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
I've bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
Merging this PR will create a GitHub release!
EOF
)
gh pr create \
--reviewer ${{ github.actor }} \
--title "Release version ${{ github.event.inputs.version }}" \
--head ${{ env.RELEASE_BRANCH }} \
--body "$BODY"
env:
# Using a bot account is important to trigger subsequent workflows.
# See https://devopsdirective.com/posts/2020/07/stupid-github-actions/#2----recursive-action.
GITHUB_TOKEN: ${{ secrets.GH_ACTION_TOKEN }}