Release #79
This file contains hidden or 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: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| releaseType: | |
| description: 'Release type (major, minor, patch)' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| dryRun: | |
| description: 'Dry run (no publish)' | |
| required: false | |
| default: false | |
| type: boolean | |
| prerelease: | |
| description: 'Pre-release' | |
| required: false | |
| default: false | |
| type: boolean | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| steps: | |
| - name: Checkout 🛎️ | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.ref }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| clean: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: '18' | |
| registry-url: 'https://registry.npmjs.org' | |
| scope: '@autonomys' | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Set Yarn version to Berry | |
| run: corepack prepare [email protected] --activate | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "GitHub Actions Bot" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Install dependencies | |
| run: yarn install | |
| - name: Generate PR-based changelog | |
| run: BUMP_TYPE=${{ inputs.releaseType }} yarn changelog | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Version bump and publish | |
| if: ${{ !inputs.dryRun }} | |
| id: version_bump | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if ${{ inputs.prerelease }}; then | |
| PRERELEASE_FLAG="--preid beta" | |
| else | |
| PRERELEASE_FLAG="" | |
| fi | |
| # Ensure npm config has auth token for @autonomys scope | |
| npm config set //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN} | |
| npm config set @autonomys:registry https://registry.npmjs.org/ | |
| git add CHANGELOG.md | |
| git commit -m "docs: update CHANGELOG.md for release" || echo "No changes to commit" | |
| yarn lerna version ${{ inputs.releaseType }} --yes --no-push --force-publish $PRERELEASE_FLAG | |
| # Get the new version after bumping | |
| NEW_VERSION=$(node -p "require('./lerna.json').version") | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| git push --follow-tags --force-with-lease | |
| yarn lerna publish from-package --yes --force-publish | |
| - name: Create GitHub Release | |
| if: ${{ !inputs.dryRun }} | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| body_path: CHANGELOG.md | |
| tag_name: v${{ steps.version_bump.outputs.version }} | |
| prerelease: ${{ inputs.prerelease }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |