Github releases and tag #7
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
name: Github releases and tag | |
on: | |
workflow_dispatch: | |
branches: [main] | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
github-release: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [21.x] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: npm install, build, and test | |
run: | | |
npm install --frozen-lockfile | |
npm run lint:ts && npm run build --if-present | |
- name: Extract Version from package.json | |
id: version | |
run: | | |
VERSION=$(node -p "require('./package.json').version") | |
echo "Extracted version: $VERSION" | |
echo "::set-output name=VERSION::$VERSION" | |
- name: Get Changelog Content (Modified) | |
id: changelog | |
run: | | |
content=$(awk '/^###/{flag=1; next} /^##/{if(flag) exit} flag' CHANGELOG.md) | |
echo "::set-output name=CHANGELOG::$content" | |
- name: Print Output Values | |
run: | | |
echo "VERSION: ${{ steps.version.outputs.VERSION }}" | |
echo "CHANGELOG_CONTENT: ${{ steps.changelog.outputs.CHANGELOG }}" | |
- name: Configure npm authentication | |
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
- name: Publish package on NPM 📦 | |
run: npm publish --tag "groovy-box-v${{ steps.version.outputs.VERSION }}" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} | |
with: | |
tag_name: "v${{ steps.version.outputs.VERSION }}" | |
release_name: "Release v${{ steps.version.outputs.VERSION }}" | |
body: | | |
**Release Changes:** | |
https://www.npmjs.com/package/groovy-box/v/${{ steps.version.outputs.VERSION }} | |
draft: false | |
prerelease: false | |
- name: Create Version Tag | |
run: | | |
git tag "v${{ steps.version.outputs.VERSION }}" | |
git push origin "v${{ steps.version.outputs.VERSION }}" | |
echo "Pushed tag: v${{ steps.version.outputs.VERSION }}" | |