-
Notifications
You must be signed in to change notification settings - Fork 55
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 creating new releases
- Loading branch information
1 parent
b95a6ad
commit 77a3976
Showing
1 changed file
with
105 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,105 @@ | ||
name: Create Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
crateName: | ||
description: 'Crate to Release' | ||
required: true | ||
default: 'mask' | ||
type: choice | ||
options: | ||
- mask | ||
- mask-parser | ||
releaseVersion: | ||
description: 'Version' | ||
required: true | ||
changelogUpdated: | ||
description: 'Is the CHANGELOG up to date?' | ||
required: true | ||
type: boolean | ||
|
||
permissions: | ||
contents: write | ||
|
||
env: | ||
VERSION: ${{ github.event.inputs.releaseVersion }} | ||
|
||
jobs: | ||
release-mask: | ||
if: ${{ github.event.inputs.crateName == 'mask' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Validate version number input | ||
run: | | ||
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "ERROR: invalid version number supplied '$VERSION'" | ||
exit 1 | ||
fi | ||
- name: Verify CHANGELOG was updated | ||
run: | | ||
if [[ "${{ github.event.inputs.changelogUpdated }}" != "true" ]]; then | ||
echo "ERROR: you must update CHANGELOG before creating a new release" | ||
exit 1 | ||
fi | ||
UNRELEASED_CHANGES=$(sed -n '/## UNRELEASED/,/## v/{//b;p}' CHANGELOG.md) | ||
if [[ "$UNRELEASED_CHANGES" == "" ]]; then | ||
echo "ERROR: CHANGELOG is missing release notes" | ||
exit 1 | ||
fi | ||
# Write the release notes to a temp file we'll use below | ||
echo "$UNRELEASED_CHANGES" > ../RELEASE_NOTES.txt | ||
- name: Set up git user | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
- name: Commit version bumps | ||
run: | | ||
# Bump the version in the changelog | ||
sed -i "s/## UNRELEASED/## UNRELEASED\\n\\n\\n## v$VERSION ($(date '+%Y-%m-%d'))/" "CHANGELOG.md" | ||
# Bump the crate version | ||
sed -i "3s/.*/version = \"$VERSION\"/" "mask/Cargo.toml" | ||
# Let cargo bump the version in the lockfile | ||
cargo check | ||
git add -A && git commit -m "Publish mask v$VERSION" | ||
git push | ||
- name: Create a new Release | ||
env: | ||
# Must use a PAT to ensure the Release workflow is triggered | ||
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow | ||
GH_TOKEN: ${{ secrets.GH_PAT_TO_TRIGGER_RELEASE_WORKFLOW }} | ||
run: | | ||
gh release create "mask/$VERSION" --title "mask v$VERSION" --notes-file ../RELEASE_NOTES.txt | ||
release-mask-parser: | ||
if: ${{ github.event.inputs.crateName == 'mask-parser' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Validate version number input | ||
run: | | ||
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "ERROR: invalid version number supplied '$VERSION'" | ||
exit 1 | ||
fi | ||
- name: Set up git user | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
- name: Commit version bumps | ||
run: | | ||
# Bump the crate version | ||
sed -i "3s/.*/version = \"$VERSION\"/" "mask-parser/Cargo.toml" | ||
# Let cargo bump the version in the lockfile | ||
cargo check | ||
git add -A && git commit -m "Publish mask-parser v$VERSION" | ||
git push | ||
- name: Create a new Release | ||
env: | ||
# Must use a PAT to ensure the Release workflow is triggered | ||
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow | ||
GH_TOKEN: ${{ secrets.GH_PAT_TO_TRIGGER_RELEASE_WORKFLOW }} | ||
run: | | ||
gh release create "mask-parser/$VERSION" --title "mask-parser v$VERSION" |