Publish #36
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
bump: | |
type: choice | |
description: "Semver version" | |
required: true | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
publish: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18.12.1 | |
registry-url: https://registry.npmjs.org/ | |
- run: npm install | |
- name: Update versions | |
id: update-versions | |
uses: ./.github/actions/bump-version | |
with: | |
bump: ${{ inputs.bump }} | |
- name: Update version in README examples | |
if: github.ref_name == 'main' | |
run: sed -i 's/weld@[0-9].[0-9].[0-9]/weld@${{ steps.update-versions.outputs.version }}/g' ./README.md | |
- uses: webfactory/ssh-agent@v0.9.0 | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
# Append -{{ ref_name }} to version number if not on production branch | |
- name: Add pre-release flag | |
if: github.ref_name != 'main' | |
run: | | |
full_version=$(echo "-${{ github.ref_name }}" | sed 's/\//-/g') | |
jq --arg v "${full_version}" '.version += $v' package.json > tmp.json | |
mv tmp.json package.json | |
- run: npm install | |
- run: head package-lock.json | |
- run: npm run check | |
- run: npm run test | |
- run: npm run build | |
- name: Commit and push to main branch | |
if: github.ref_name == 'main' | |
run: | | |
git config --global user.name "GitHub Action" | |
git config --global user.email "username@users.noreply.github.com" | |
git commit -a -m "Update package.json to next ${{ inputs.bump }} version" | |
git tag -a ${{ steps.update-versions.outputs.version }} -m "Version ${{ steps.update-versions.outputs.version }}" | |
git push origin ${{ steps.update-versions.outputs.version }} | |
git push origin main | |
- name: Publish to registry | |
if: github.ref_name == 'main' | |
run: npm publish | |
working-directory: dist/ | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Publish to registry pre-release | |
if: github.ref_name != 'main' | |
run: npm publish --tag ${{ github.ref_name }} | |
working-directory: dist/ | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: github.ref_name == 'main' | |
with: | |
tag_name: ${{ steps.update-versions.outputs.version }} | |
generate_release_notes: true | |
make_latest: "true" | |
prerelease: false | |
draft: false |