|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_type: |
| 7 | + description: "Type of release (prerelease, prepatch, patch, minor, preminor, major)" |
| 8 | + required: true |
| 9 | + default: "patch" |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - uses: pnpm/action-setup@v3 |
| 20 | + with: |
| 21 | + version: 8 |
| 22 | + |
| 23 | + - name: Configure Git |
| 24 | + run: | |
| 25 | + git config user.name "${{ github.actor }}" |
| 26 | + git config user.email "${{ github.actor }}@users.noreply.github.com" |
| 27 | +
|
| 28 | + - name: "Setup npm for npmjs" |
| 29 | + run: | |
| 30 | + npm config set registry https://registry.npmjs.org/ |
| 31 | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc |
| 32 | +
|
| 33 | + - name: Install Protobuf Compiler |
| 34 | + run: sudo apt-get install -y protobuf-compiler |
| 35 | + |
| 36 | + - name: Install dependencies |
| 37 | + run: pnpm install |
| 38 | + |
| 39 | + - name: Build packages |
| 40 | + run: pnpm run build |
| 41 | + |
| 42 | + - name: Tag and Publish Packages |
| 43 | + id: tag_publish |
| 44 | + run: | |
| 45 | + npx lerna version ${{ github.event.inputs.release_type }} --conventional-commits --yes --no-private --force-publish |
| 46 | + npx lerna publish from-git --yes --dist-tag ${{ github.event.inputs.release_type == 'preminor' && 'next' || 'latest' }} |
| 47 | +
|
| 48 | + - name: Get Version Tag |
| 49 | + id: get_tag |
| 50 | + run: echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT |
| 51 | + |
| 52 | + - name: Generate Release Body |
| 53 | + id: release_body |
| 54 | + run: | |
| 55 | + if [ -f CHANGELOG.md ]; then |
| 56 | + echo "body=$(cat CHANGELOG.md)" >> $GITHUB_OUTPUT |
| 57 | + else |
| 58 | + echo "body=No changelog provided for this release." >> $GITHUB_OUTPUT |
| 59 | + fi |
| 60 | +
|
| 61 | + - name: Create GitHub Release |
| 62 | + uses: actions/create-release@v1 |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin |
| 66 | + with: |
| 67 | + tag_name: ${{ steps.get_tag.outputs.TAG }} |
| 68 | + release_name: Release |
| 69 | + body_path: CHANGELOG.md |
| 70 | + draft: false |
| 71 | + prerelease: false |
0 commit comments