Skip to content

Commit

Permalink
build: add workflow to auto bump version (#886)
Browse files Browse the repository at this point in the history
* add workflow to auto bump version

* test on pr

* use latest node action

* pin major

* manually fetch tags, i guess

* harness the actions

* more better

* use gh

* need token

* restore manual trigger

* just normal checkout

* do the command

* Update .github/workflows/bump.yml

Co-authored-by: Alex Plischke <[email protected]>

* whitespace fix

* add a directive to choose a release type

* make sure we don't friggin' release

* restore

* Trigger the release workflow when a release has been released...

Since the bump workflow uses `gh release create` to create a release,
the tag created with that command is surprisingly not a "pushed" tag so
the existing event trigger for the release workflow isn't satisfied (its
looking for a "push").

* Revert "Trigger the release workflow when a release has been released..."

This reverts commit 4f8f897.

* use da correct token

---------

Co-authored-by: Alex Plischke <[email protected]>
  • Loading branch information
mhan83 and alexplischke authored Feb 15, 2024
1 parent a1fb840 commit 764e9e2
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Bump

on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release type'
type: choice
required: true
default: '<Choose one>'
options:
- <Choose one>
- patch
- minor
- major

jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Validate input
run: |
if [[ "${{ github.event.inputs.releaseType }}" == "<Choose one>" ]]; then
printf "You must choose a release type (patch, minor, or major)" >&2
exit 1
fi
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: v20

- name: Get latest version
id: latest
run: |
LATEST=$(gh release list \
--exclude-drafts \
--exclude-pre-releases \
--json name,isLatest \
--jq '.[] | select(.isLatest == true) | .name')
echo "version=$LATEST" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

- name: Get next version
id: next
run: |
NEXT=$(npx --yes semver -i ${{ github.event.inputs.releaseType }} ${{ steps.latest.outputs.version }})
echo "version=$NEXT" >> "$GITHUB_OUTPUT"
- name: Generate release
if: ${{ steps.next.outputs.version != '' }}
run: gh release create v${{ steps.next.outputs.version }} --generate-notes
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

0 comments on commit 764e9e2

Please sign in to comment.