Skip to content

Publish @digabi/user-management #157

Publish @digabi/user-management

Publish @digabi/user-management #157

Workflow file for this run

name: 'Publish new version'
on:
workflow_dispatch:
inputs:
package:
type: choice
description: Package
options:
- '@digabi/2fa'
- '@digabi/answer-utils'
- '@digabi/async-utils'
- '@digabi/crypto-utils'
- '@digabi/database-utils'
- '@digabi/eslint-config'
- '@digabi/examination-utils'
- '@digabi/express-utils'
- '@digabi/fetch'
- '@digabi/json-exam-utils'
- '@digabi/logger'
- '@digabi/passphrase-generator'
- '@digabi/passport-utils'
- '@digabi/passport-saml-cache-postgres'
- '@digabi/saml-mock'
- '@digabi/testing'
- '@digabi/typescript-config'
- '@digabi/user-management'
- '@digabi/validation'
- '@digabi/zip-utils'
bump:
type: choice
description: Version bump
options:
- major
- minor
- patch
- premajor
- preminor
- prepatch
- prerelease
run-name: 'Publish ${{ inputs.package }}'
concurrency:
group: publish-queue # Publish jobs fail if ran simultaneously
permissions:
id-token: write # Required for NPM Trusted publishing
contents: write
jobs:
publish:
name: Publish new version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-node@v7
with:
node-version-file: '.nvmrc'
cache: 'npm'
# Ensure npm 11.5.1 or later is installed
- name: Update npm
run: npm install -g npm@latest
- run: npm ci
- run: npm run lint --workspace=${{ inputs.package }}
- run: npm run test --workspace=${{ inputs.package }}
- name: Setup git config
run: |
git config --global user.email "ci@ylioppilastutkinto.fi"
git config --global user.name "Github CI"
- name: Get NPM tag name
id: npm-tag
run: |
TAG=latest
if [[ "${{ inputs.bump }}" == *pre* ]]; then
branchName="${{ github.ref_name }}"
TAG=${branchName//\//-}
fi
echo "value=$TAG" >> $GITHUB_OUTPUT
- name: Bump package version
run: |
TAG=${{ steps.npm-tag.outputs.value }}
npm version ${{ inputs.bump }} --preid="$TAG" --workspace=${{ inputs.package }}
- name: Get git tag name
id: git-tag
run: |
VERSION=$(npm version --json --workspace=${{ inputs.package }} | jq -r '."${{ inputs.package }}"')
GIT_TAG_NAME=${{ inputs.package }}@$VERSION
echo "value=$GIT_TAG_NAME" >> $GITHUB_OUTPUT
- name: Create release commit
run: |
TAG=${{ steps.npm-tag.outputs.value }}
GIT_TAG_NAME=${{ steps.git-tag.outputs.value }}
git add **/package.json package-lock.json
git commit -m "CI: Release $GIT_TAG_NAME with tag $TAG"
- name: Create tag
run: |
GIT_TAG_NAME=${{ steps.git-tag.outputs.value }}
git tag -a $GIT_TAG_NAME -m $GIT_TAG_NAME
- name: Publish to npm and push to git
run: |
TAG=${{ steps.npm-tag.outputs.value }}
npm publish --workspace=${{ inputs.package }} --tag=$TAG
git push && git push --tags