Release - Tag, release, publish #17
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Release - Tag, release, publish | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
inputs: | |
tagName: | |
description: 'Tag name' | |
required: false | |
env: | |
node_version: 20.x | |
pnpm_version: 8.x | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout branch ${{ github.ref }} | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
fetch-depth: 0 | |
- name: Setup pnpm ${{ env.pnpm_version }} | |
uses: pnpm/action-setup@v2.4.0 | |
with: | |
version: ${{ env.pnpm_version }} | |
- name: Setup Node.js ${{ env.node_version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.node_version }} | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'pnpm' | |
- name: install dependencies | |
run: pnpm install | |
- name: Release | |
run: | | |
# setup git creds | |
git config user.name "GitHub Release Bot" | |
git config user.email "<>" | |
# generate release | |
pnpm run release | |
- name: Push to remote | |
run: | | |
# Check status | |
git status | |
git diff --color -U0 | cat | |
# push changes | |
git push origin --follow-tags | |
publish: | |
needs: release | |
name: Publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout branch ${{ github.ref }} | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
fetch-depth: 0 | |
- name: Setup pnpm ${{ env.pnpm_version }} | |
uses: pnpm/action-setup@v2.4.0 | |
with: | |
version: ${{ env.pnpm_version }} | |
- name: Setup Node.js ${{ env.node_version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.node_version }} | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'pnpm' | |
- name: install dependencies | |
run: pnpm install | |
- name: Publish to npm | |
run: pnpm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Generate Release changelog | |
run: pnpm run release:changelog | |
- name: Fetch latest tag | |
if: ${{ github.event_name == 'workflow_run' || (github.event_name == 'workflow_dispatch' && github.event.inputs.tagName == '') }} | |
id: latest-tag | |
run: | | |
tag_name=$(git describe --abbrev=0) | |
echo "Tag found: '$tag_name'" | |
echo "::set-output name=TAG_NAME::$tag_name" | |
- name: Push Release to github | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ github.event.inputs.tagName || steps.latest-tag.outputs.TAG_NAME || github.ref}} | |
body_path: RELEASE.md |