-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logic to do automated Github releases (#21)
Add logic to create a new automated GH release whenever the version in package.json is bumped and merged into mainline.
- Loading branch information
Showing
3 changed files
with
50 additions
and
16 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 |
---|---|---|
@@ -1,27 +1,61 @@ | ||
name: Version 🔖 | ||
|
||
on: | ||
release: | ||
types: [created] | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'package.json' | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
version: | ||
name: Release | ||
release: | ||
runs-on: ubuntu-latest | ||
environment: release | ||
permissions: | ||
contents: read | ||
contents: write | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get version from package.json | ||
id: package_version | ||
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | ||
|
||
- name: Check if tag exists | ||
id: check_tag | ||
run: | | ||
git fetch --tags | ||
if git rev-parse "v${{ steps.package_version.outputs.VERSION }}" >/dev/null 2>&1; then | ||
echo "::set-output name=EXISTS::true" | ||
fi | ||
- name: Create Release | ||
if: steps.check_tag.outputs.EXISTS != 'true' | ||
uses: softprops/action-gh-release@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: v${{ steps.package_version.outputs.VERSION }} | ||
name: Release v${{ steps.package_version.outputs.VERSION }} | ||
draft: false | ||
prerelease: false | ||
generate_release_notes: true | ||
make_latest: true | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
registry-url: "https://registry.npmjs.org" | ||
- run: npm install -g npm@^9.5.0 | ||
- run: npm ci | ||
- run: npm publish --provenance --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Publish to NPM | ||
run: | | ||
npm install -g npm@^9.5.0 | ||
npm ci | ||
npm publish --provenance --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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