Skip to content

Release

Release #19

Workflow file for this run

name: Release
on:
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
cache: npm
- run: npm install
- run: npm run check
- run: npm test
- run: npm run build
- name: Calculate calendar version
id: version
run: |
today=$(date -u +"%Y.%-m.%-d")
existing=$(git tag --list "v${today}*" | sort -V)
if [ -z "$existing" ]; then
version="$today"
else
last=$(echo "$existing" | tail -1)
if [ "$last" = "v${today}" ]; then
version="${today}-1"
else
suffix=$(echo "$last" | sed "s/v${today}-//")
next=$((suffix + 1))
version="${today}-${next}"
fi
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Releasing v${version}"
- name: Bump version, commit, and tag
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
npm version "${VERSION}" --no-git-tag-version
git add package.json package-lock.json
git diff --cached --quiet && echo "Version already ${VERSION}, skipping commit" || git commit -m "${VERSION}"
git tag -f "v${VERSION}"
git push origin main --tags
- name: Publish to npm
run: |
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
run: gh release create "v${VERSION}" --title "v${VERSION}" --generate-notes