Bump version & publish #43
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: 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 | |
echo "3. git add" | |
git add . | |
echo "4. git commit ${{ github.event.inputs.package }} v$(npm pkg get version | head -n 1 | tr -d '"')" | |
git commit -m "${{ github.event.inputs.package }} v$(npm pkg get version | head -n 1 | tr -d '"')" | |
echo "5. git tag $(npm pkg get name | head -n 1 | tr -d '"' | sed -e 's/@mediamonks\///g')@$(npm pkg get version | head -n 1 | tr -d '"')" | |
git tag $(npm pkg get name | head -n 1 | tr -d '"' | sed -e 's/@mediamonks\///g')@$(npm pkg get version | head -n 1 | tr -d '"') | |
- 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 }} | |
- name: Push latest version | |
if: ${{ github.event.inputs.dryrun == 'false' }} | |
run: git push origin main --tags |