Skip to content

Commit

Permalink
publish tags
Browse files Browse the repository at this point in the history
  • Loading branch information
eifel-tech committed Oct 23, 2024
1 parent 665688d commit 8cd5f56
Showing 1 changed file with 38 additions and 24 deletions.
62 changes: 38 additions & 24 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,43 @@

name: Publish

on: workflow_dispatch
on: push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
if: |
contains(github.event.head_commit.message, '[skip ci]') == false &&
startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Extract the version and commit body from the tag
shell: bash
id: extract_release
run: |
VERSION="${{ github.ref }}"
VERSION=${VERSION##*/v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
EOF=$(od -An -N6 -x /dev/urandom | tr -d ' ')
BODY=$(git show -s --format=%b)
echo "BODY<<$EOF" >> $GITHUB_OUTPUT
echo "$BODY" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
if [[ $VERSION == *"-"* ]] ; then
echo "TAG=--tag next" >> $GITHUB_OUTPUT
fi
- name: Publish package to npm
shell: bash
run: |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm whoami
npm publish ${{ steps.extract_release.outputs.TAG }}

0 comments on commit 8cd5f56

Please sign in to comment.