Skip to content

Bump version & publish #44

Bump version & publish

Bump version & publish #44

name: Bump version & publish
on:
workflow_dispatch:
inputs:
package:
description: 'Select package'
required: true
type: choice
options:
- 'channels'
- 'use-channels'
version:
description: 'Semver type of new version'
required: true
type: choice
options:
- major
- minor
- patch
dryrun:
description: 'Dry run (will not publish and tag)'
required: false
type: boolean
jobs:
bump-version:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Check out source
uses: actions/checkout@v3
with:
ssh-key: ${{secrets.DEPLOY_KEY}}
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install npm packages
run: npm ci
- name: build (for testing)
if: ${{ github.event.inputs.package == 'use-channels' }}
run: npm run build -w packages/channels
- name: Run tests
run: |
cd packages/${{ github.event.inputs.package }}
npm run test
- name: Build
run: |
cd packages/${{ github.event.inputs.package }}
npm run build
- name: Setup Git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: bump version
run: |
echo "1. cd packages/${{ github.event.inputs.package }}"
cd packages/${{ github.event.inputs.package }}
echo "2. npm version ${{ github.event.inputs.version }}"
npm version ${{ github.event.inputs.version }} --no-git-tag-version
version=$(npm pkg get version | tr -d '{}' | tr -d '"' | awk -F ': ' '{ print $2 }' | tr -d '\n')
echo "3. git add"
git add .
echo "4. git commit -m ${{ github.event.inputs.package }} v$version"
git commit -m "${{ github.event.inputs.package }} v$version"
echo "5. git tag ${{ github.event.inputs.package }}@$version"
git tag ${{ github.event.inputs.package }}@$version
- name: Push latest version
if: ${{ github.event.inputs.dryrun == 'false' }}
run: git push origin main --tags
- name: publish
if: ${{ github.event.inputs.dryrun == 'false' }}
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --workspace=packages/${{ github.event.inputs.package }} --provenance
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}