Skip to content

Publish package

Publish package #18

Workflow file for this run

name: Publish package
on:
workflow_dispatch:
inputs:
release-type:
description: |
Release Type
required: true
type: choice
options:
- patch
- minor
- major
- prepatch
- preminor
- premajor
- prerelease
package:
description: |
Package to publish
required: true
type: choice
options:
- "@geneontology/web-components"
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
outputs:
previous_version: ${{ steps.increment_version.outputs.previous_version }}
new_version: ${{ steps.increment_version.outputs.new_version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
cache: "npm"
- name: Install dependencies
run: npm ci
# This git user config is recommended by the actions/checkout documentation
# https://github.com/actions/checkout/tree/v4.2.2?tab=readme-ov-file#push-a-commit-using-the-built-in-token
- name: Configure git user
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Increment version for ${{ inputs.package }}
id: increment_version
run: |
echo 'previous_version='$(npm pkg get version --workspaces | jq -r '."${{ inputs.package }}"') >> $GITHUB_OUTPUT
npm version --preid=beta --no-git-tag-version --workspace ${{ inputs.package }} ${{ inputs.release-type }}
echo 'new_version='$(npm pkg get version --workspaces | jq -r '."${{ inputs.package }}"') >> $GITHUB_OUTPUT
- name: Commit version change
run: |
git commit -a -m "${{ steps.increment_version.outputs.new_version }}"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm run build
- name: Publish to NPM
run: npm publish --provenance --access public --workspace ${{ inputs.package }}
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: website/build
deploy_docs:
runs-on: ubuntu-latest
needs: publish
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
create_release:
runs-on: ubuntu-latest
needs: publish
if: ${{ !startsWith(inputs.release-type, 'pre') }}
permissions:
contents: write
steps:
- name: Create GitHub Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
tag_name: v${{ needs.publish.outputs.new_version }}
generate_release_notes: true
prerelease: ${{ startsWith(inputs.release-type, 'pre') }}