Skip to content

Release from main

Release from main #141

name: Release
run-name: 'Release from ${{ github.ref_name }}'
on:
workflow_dispatch:
inputs:
type:
description: |
Select the branch to release from above, then select the version level to bump below.
type: choice
options:
- major
- minor
- patch
default: minor
jobs:
bump-version:
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ steps.create_tags.outputs.RELEASE_VERSION }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- run: npm ci
- name: Bump version and regenerate README
run: |
# https://github.com/orgs/community/discussions/26560
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
VERSION=$(npm version ${{inputs.type}} --no-git-tag-version)
npx oclif readme && node src/format-readme.js
git commit -am "Release for ${VERSION}"
git tag $VERSION
echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Released version ${VERSION}" >> $GITHUB_STEP_SUMMARY
id: create_tags
- run: git push origin --follow-tags
publish-github:
runs-on: ubuntu-latest
needs: bump-version
permissions:
contents: write
env:
VERSION: ${{ needs.bump-version.outputs.RELEASE_VERSION }}
steps:
- name: Create GitHub Release
uses: octokit/[email protected]
id: create_release
with:
route: POST /repos/{owner}/{repo}/releases
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
tag_name: ${{ env.VERSION }}
name: ${{ env.VERSION }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm:
runs-on: ubuntu-latest
needs: [bump-version, publish-github]
env:
VERSION: ${{ needs.bump-version.outputs.RELEASE_VERSION }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ env.VERSION }}
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}