Skip to content

Commit

Permalink
Add auto-publish on push to release branch
Browse files Browse the repository at this point in the history
  • Loading branch information
firefoxic committed Aug 14, 2024
1 parent 611d71b commit cb6fdf6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
push:
branches:
- release

permissions:
contents: write
id-token: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: pnpm
- run: pnpm install
- run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
RELEASE_DESCRIPTION=$(awk '/## \[Unreleased\]/{flag=1; next} /## \[/{flag=0} flag' ./CHANGELOG.md | sed '/^[[:space:]]*$/d')
if echo "$RELEASE_DESCRIPTION" | grep -q '### Changed'; then
pnpm version major
elif echo "$RELEASE_DESCRIPTION" | grep -q '### Added'; then
pnpm version minor
elif echo "$RELEASE_DESCRIPTION" | grep -q '### Fixed'; then
pnpm version patch
fi
echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "RELEASE_DESCRIPTION<<EOF" >> $GITHUB_ENV
echo "$RELEASE_DESCRIPTION" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME }}
name: "Release ${{ env.TAG_NAME }}"
body: ${{ env.RELEASE_DESCRIPTION }}
draft: false
prerelease: false
- run: git fetch --all && git switch main && git rebase release && git push origin main
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"test": "node --test",
"preversion": "pnpm test",
"version": "update-changelog",
"postversion": "pnpm publish --access=public",
"postversion": "pnpm publish --provenance --access public --no-git-checks",
"postpublish": "git push --follow-tags"
},
"devDependencies": {
Expand Down

0 comments on commit cb6fdf6

Please sign in to comment.