diff --git a/.github/workflows/deploy-cocoapods.yml b/.github/workflows/deploy-cocoapods.yml index ca18d27..081c30a 100644 --- a/.github/workflows/deploy-cocoapods.yml +++ b/.github/workflows/deploy-cocoapods.yml @@ -10,6 +10,7 @@ permissions: jobs: build: name: Deploy to Cocoapods + if: startsWith(github.event.release.tag_name, 'v') runs-on: macOS-latest steps: - name: Harden the runner (Audit all outbound calls) diff --git a/.github/workflows/draft-new-release.yml b/.github/workflows/draft-new-release.yml index 0415748..263706b 100644 --- a/.github/workflows/draft-new-release.yml +++ b/.github/workflows/draft-new-release.yml @@ -47,7 +47,7 @@ jobs: run: | source_branch_name=${GITHUB_REF##*/} release_type=release - git fetch origin master --depth=1 + git fetch origin master git merge origin/master current_version=$(jq -r .version package.json) diff --git a/.github/workflows/publish-new-release.yml b/.github/workflows/publish-new-release.yml index 5be5126..3241239 100644 --- a/.github/workflows/publish-new-release.yml +++ b/.github/workflows/publish-new-release.yml @@ -13,7 +13,7 @@ permissions: jobs: release: permissions: - contents: read # GITHUB_TOKEN only needs read for checkout + contents: read # GitHub App token handles release writes name: Publish new release runs-on: ubuntu-latest if: startsWith(github.event.pull_request.head.ref, 'release/') && github.event.pull_request.merged == true # only merged pull requests must trigger this job @@ -39,25 +39,24 @@ jobs: VERSION="${BRANCH_NAME#release/}" echo "release_version=$VERSION" >> $GITHUB_OUTPUT - - name: Checkout source branch - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - with: - token: ${{ steps.generate-token.outputs.token }} - fetch-depth: 0 - - - name: Set Node 16 - uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3.9.1 - with: - node-version: 16 - - - name: Create Github Release - id: create_release + - name: Publish GitHub release env: - HUSKY: 0 - GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} - CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{ steps.generate-token.outputs.token }} + GH_TOKEN: ${{ steps.generate-token.outputs.token }} + VERSION: ${{ steps.extract-version.outputs.release_version }} run: | - npx conventional-github-releaser -p angular + TAG="v${VERSION}" + + if gh release view "$TAG" --repo "${{ github.repository }}" >/dev/null 2>&1; then + echo "Release $TAG already exists; nothing to publish." + exit 0 + fi + + gh release create "$TAG" \ + --repo "${{ github.repository }}" \ + --verify-tag \ + --title "$TAG" \ + --generate-notes \ + --latest - name: Delete release branch uses: koj-co/delete-merged-action@63a03c35810a8a7d4840d18793c0f68ff8b59450 # master @@ -65,4 +64,4 @@ jobs: with: branches: 'release/*' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}