From 86c24abd88e4ea95a9b6889d6c2b5d29f108773c Mon Sep 17 00:00:00 2001 From: Mohsin Zaidi <2236875+smrz2001@users.noreply.github.com> Date: Mon, 22 Jan 2024 11:34:57 -0500 Subject: [PATCH] feat: updated release workflow --- .github/workflows/cd-to-infra.yml | 3 +++ .github/workflows/publish-release.yml | 16 ++++++++++------ ci-scripts/release_pr.sh | 7 ++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cd-to-infra.yml b/.github/workflows/cd-to-infra.yml index 8966ee022..e3f948851 100644 --- a/.github/workflows/cd-to-infra.yml +++ b/.github/workflows/cd-to-infra.yml @@ -1,5 +1,8 @@ name: Continuous Deployment to Infra +permissions: + contents: write + on: push: branches: [ "main" ] diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index f892e46eb..b14a77cc4 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -6,15 +6,16 @@ permissions: on: push: - branches: [ "main" ] + # TODO: Change to main + branches: [ "feature/cd" ] paths: - 'Cargo.toml' jobs: - # Build and packages all the things + # Build and package all the things build-binaries: if: | - contains(github.event.head_commit.message, 'chore: Release') + contains(github.event.head_commit.message, 'chore: version v') strategy: matrix: # For these target platforms @@ -82,8 +83,8 @@ jobs: runs-on: ubuntu-latest env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Use PAT to allow release events to be triggered via this workflow + GH_TOKEN: ${{ secrets.GH_TOKEN_PAT }} steps: - uses: actions/checkout@v3 with: @@ -100,4 +101,7 @@ jobs: run: | export TAG=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' | tr -d '"') echo "Releasing "$TAG - gh release create "v${TAG}" -n "Release of ${TAG}" -t "v${TAG}" --latest artifacts/**/*.tar.gz \ No newline at end of file + # Generate a GitHub pre-release. This will trigger the "prereleased" event that will deploy to Clay. When the + # pre-release is promoted to a release from the GitHub console, the "released" event will trigger and deploy + # to Prod. + gh release create "v${TAG}" -t "v${TAG}" --generate-notes --prerelease --latest artifacts/**/*.tar.gz diff --git a/ci-scripts/release_pr.sh b/ci-scripts/release_pr.sh index 2b9d3aafa..9ab55bf21 100755 --- a/ci-scripts/release_pr.sh +++ b/ci-scripts/release_pr.sh @@ -63,15 +63,16 @@ cargo update -p ceramic-api-server # Commit the specified packages # `cargo release commit` currently fails to build a good commit message. # Using git commit directly for now -branch="release-v${version}" +branch="version-v${version}" git checkout -b "$branch" -msg="chore: release version v${version}" +msg="chore: version v${version}" git commit -am "$msg" git push --set-upstream origin $branch # Create a PR +# TODO: Change to main gh pr create \ - --base main \ + --base "feature/cd" \ --head "$branch" \ --label release \ --title "$msg" \