name: Publish Release on: pull_request: types: [closed] branches: - main jobs: publish: if: github.event.pull_request.merged == true runs-on: ubuntu-latest outputs: bump_type: ${{ steps.determine_version.outputs.bump_type }} steps: - name: "Checkout" uses: actions/checkout@v2 with: fetch-depth: 0 - name: "Setup Node.js" uses: actions/setup-node@v2 with: node-version: '20.x' - uses: webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - name: "Determine Version Bump" id: determine_version env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # Get PR labels labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') # Default to patch if no valid label is found bump_type="none" # Check for major, minor, or patch labels for label in $labels; do if [[ "$label" == "bump:major" ]]; then bump_type="major" break elif [[ "$label" == "bump:minor" ]]; then bump_type="minor" elif [[ "$label" == "bump:patch" ]]; then bump_type="patch" fi done echo "bump_type=$bump_type" >> "$GITHUB_OUTPUT" - name: "Version and Publish" id: version_and_publish if : ${{ steps.determine_version.outputs.bump_type != 'none' }} run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" # Run Lerna with the determined bump type npx lerna version ${{ steps.determine_version.outputs.bump_type }} --yes # Fetch the most recent tag latest_tag=$(git describe --tags --abbrev=0) echo "latest_tag=$latest_tag" >> "$GITHUB_OUTPUT" - name: "Publish GitHub Release" if: ${{ steps.determine_version.outputs.bump_type != 'none' }} uses: softprops/action-gh-release@v2 with: prerelease: false draft: false make_latest: true generate_release_notes: true discussion_category_name: Announcements tag_name: ${{ steps.version_and_publish.outputs.latest_tag }} name: ${{ steps.version_and_publish.outputs.latest_tag }} npm-release: needs: - publish uses: ./.github/workflows/npm_release.yml if: ${{ needs.publish.outputs.bump_type != 'none' }} secrets: inherit