Skip to content

Publish Release

Publish Release #1

Workflow file for this run

name: Publish Release
on:
release:
types: [created]
jobs:
release:
name: Publish Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: './pnpm-lock.yaml'
- name: Install dependencies
run: pnpm install
- name: Lint project
run: pnpm lint
- name: Extract version from tag
id: extract_version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
# Updates the version in the package.json
- name: Set package version
uses: ZeWaka/set-node-package-version@v1
with:
version: ${{ steps.extract_version.outputs.version }}
- name: Build project
run: pnpm build
- name: Commit changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Build & Release ${{ github.event.release.tag_name }}" || echo "No changes to commit"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Get new Git SHA
id: get_sha
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Update tag to latest commit
run: |
git tag -f ${{ github.event.release.tag_name }} ${{ steps.get_sha.outputs.sha }}
git push origin ${{ github.event.release.tag_name }} --force
- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
- name: Update Release
uses: tubone24/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.event.release.tag_name }}
with:
release_name: ${{ github.event.release.tag_name }}
body: ${{steps.build_changelog.outputs.changelog}}
draft: false
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}