Skip to content

Commit

Permalink
feat: updated release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed Jan 22, 2024
1 parent 4a55ed9 commit dfed18a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/cd-to-infra.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: Continuous Deployment to Infra

permissions:
contents: write

on:
push:
branches: [ "main" ]
release:
types: [created, published, edited, prereleased, released]
# TODO: We can scope release types once we're able to get reliable behavior with event triggers
# types: [prereleased, released]

env:
AWS_REGION: ${{ secrets.AWS_REGION }}
Expand Down Expand Up @@ -37,7 +41,7 @@ jobs:
run: |
SHA_TAG=$(echo ${{ github.SHA }} | head -c 12)
DEPLOY_TAG=$SHA_TAG
if [[ ${{ contains(github.event.head_commit.message, 'chore: Release') }} == 'true' ]]; then
if [[ ${{ contains(github.event.head_commit.message, 'chore: version v') }} == 'true' ]]; then
RELEASE_TAG=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' | tr -d '"')
# Use the release tag to deploy, if one is available.
DEPLOY_TAG=$RELEASE_TAG
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ permissions:
contents: write

on:
# Run this workflow against any branch that updates the TOML file. This can be used to create (pre)releases from any
# branch (e.g. for hotfixes) without affecting the main branch.
push:
branches: [ "main" ]
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
Expand Down Expand Up @@ -82,8 +83,9 @@ 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 }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PAT }}
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -100,4 +102,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
# 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 artifacts/**/*.tar.gz
15 changes: 8 additions & 7 deletions ci-scripts/release_pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ 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}"
git checkout -b "$branch"
msg="chore: release version v${version}"
current_branch=$(git rev-parse --abbrev-ref HEAD)
pr_branch="version-v${version}"
git checkout -b "$pr_branch"
msg="chore: version v${version}"
git commit -am "$msg"
git push --set-upstream origin $branch
git push --set-upstream origin "$pr_branch"

# Create a PR
# Create a PR against the branch this workflow is running on
gh pr create \
--base main \
--head "$branch" \
--base "$current_branch" \
--head "$pr_branch" \
--label release \
--title "$msg" \
--body "$release_notes"

0 comments on commit dfed18a

Please sign in to comment.