ccctool-lib
Version:
47 lines (37 loc) • 1.28 kB
YAML
name: Test and Release on Tag
on:
release:
types: [published]
jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Check tag format
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Tag $TAG_NAME does not match the required format vX.Y.Z"
exit 1
fi
echo "Tag format is correct: $TAG_NAME"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
run: npm install
- name: Run Jest tests
run: npm test
- name: Set version from Git tag
run: |
VERSION=$(echo ${GITHUB_REF#refs/tags/}) # Git-Tag extrahieren
echo "Setting version to $VERSION"
jq --arg VERSION "$VERSION" '.version = $VERSION' package.json > temp.json && mv temp.json package.json
- name: Authenticate with npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Publish package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public