Workflow file for this run
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 Release + Publish Packages | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
jobs: | |
release: | |
needs: build | |
name: Publish GitHub Release | |
if: github.event.repository.fork == false | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: step-security/harden-runner@v1 | |
with: | |
allowed-endpoints: api.github.com:443 | |
github.com:443 | |
- name: Get version from tag | |
id: tag_name | |
run: echo "current_version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT" | |
shell: bash | |
- uses: actions/checkout@v3 | |
- uses: mindsers/changelog-reader-action@v2 | |
id: changelog_reader | |
with: | |
version: ${{ steps.tag_name.outputs.current_version }} | |
- name: Get common links from changelog | |
id: changelog | |
run: | | |
# Parse the changelog for common links | |
_links="$(grep -P '^\[\D*]:.+' ${GITHUB_WORKSPACE}/CHANGELOG.md | sort -u)" | |
_links="${_links//'%'/'%25'}" | |
_links="${_links//$'\n'/'%0A'}" | |
_links="${_links//$'\r'/'%0D'}" | |
# Set output 'links' to $_links | |
DELIMITER=$(uuidgen) | |
echo "links<<${DELIMITER}" >> "${GITHUB_OUTPUT}" | |
echo "$_links" >> "${GITHUB_OUTPUT}" | |
echo "${DELIMITER}" >> "${GITHUB_OUTPUT}" | |
- uses: softprops/action-gh-release@v1 | |
with: | |
body: | | |
${{ steps.changelog_reader.outputs.changes }} | |
${{ steps.changelog.outputs.links }} | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Get PNPM store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- name: Setup PNPM cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run tests | |
run: pnpm test | |
publish-npm: | |
needs: release | |
name: Publish NPM Package | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: "https://registry.npmjs.org" | |
always-auth: true | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Get PNPM store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- name: Setup PNPM cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install | |
- name: Publish package | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |