Skip to content

preminor version for testing #10

preminor version for testing

preminor version for testing #10

Workflow file for this run

name: Publish
on:
push:
jobs:
version:
runs-on: ubuntu-latest
outputs:
description: "New version identifier (if changed)"
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
sparse-checkout: package.json
- name: Check version
id: version
run: |
set -e -o pipefail
BEFORE_VERSION=$(git show "${{ github.event.before }}:package.json" | jq -r .version)
AFTER_VERSION=$(git show "${{ github.event.after }}:package.json" | jq -r .version)
if [ "$BEFORE_VERSION" != "$AFTER_VERSION" ]; then
echo "Version changed from $BEFORE_VERSION to $AFTER_VERSION"
echo "version=$AFTER_VERSION" >> "$GITHUB_OUTPUT"
fi
tag:
runs-on: ubuntu-latest
permissions:
contents: write
# We only tag on pushes to main, when the version has changed
needs: version
if: github.ref == 'refs/heads/main' && ${{ needs.version.outputs.version != '' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: package.json
- name: Tag version
run: |
set -e -o pipefail
git tag "${{ needs.version.outputs.version }}" "${{ github.event.after }}"
git push origin "${{ needs.version.outputs.version }}"
publish:
runs-on: ubuntu-latest
permissions:
packages: write
# Version changes in any branch can be published
needs: version
if: ${{ needs.version.outputs.version != '' }}
steps:
- name: Checkout commit
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
registry-url: https://npm.pkg.github.com
scope: '@alveusgg'
- name: Cache optimized assets
uses: actions/cache@v4
with:
path: build/assets
key: optimized-assets-${{ hashFiles('src/assets/**') }}
restore-keys: |
optimized-assets-
- name: Install dependencies
run: npm ci
# If this push wasn't to main, add the commit hash to the version
- name: Update version
if: github.ref != 'refs/heads/main'
run: |
set -e -o pipefail
CURRENT_VERSION=$(jq -r .version package.json)
NEW_VERSION="$CURRENT_VERSION-pre.${{ github.event.after }}"
npm version --no-git-tag-version "$NEW_VERSION"
- name: Publish package
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}