Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rs]build(gh): simplify RS release workflow #730

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions .github/workflows/rs-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow is triggered by a tag that matches the pattern rs/v*-pin.
# This workflow is triggered by a tag that matches the pattern rs/v*.
# Essentially it does the following:
# - gathers release info including its version using created tag
# - applies version to the workspace and updates crates dependencies
Expand All @@ -13,7 +13,7 @@ name: '[rs] Release'
on:
push:
tags:
- 'rs/v*-pin'
- 'rs/v*'

env:
# see https://api.github.com/users/github-actions%5Bbot%5D
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
outputs:
rc_branch: ${{ steps.rc_branch.outputs.branch }}
r_version: ${{ steps.release_info.outputs.version }}
r_tag: rs/v${{ steps.release_info.outputs.version }}
r_tag: ${{ steps.release_info.outputs.r_tag }}

steps:
- name: Checkout Code
Expand All @@ -53,39 +53,35 @@ jobs:
- name: Extract Release Info
id: release_info
run: |
PIN_TAG=${GITHUB_REF#refs/tags/}
VERSION=${PIN_TAG#rs/v}
VERSION="${VERSION%-pin}"
R_TAG=${GITHUB_REF#refs/tags/}
VERSION=${R_TAG#rs/v}
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?$ ]]; then
echo "'$VERSION' is not a valid semver version"
exit 1
fi
echo "Pin Tag: $PIN_TAG"
echo "pin_tag=$PIN_TAG" >> $GITHUB_OUTPUT
echo "Release Tag: $R_TAG"
echo "r_tag=$R_TAG" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Set Workspace Version
run: |
sed -i "s/^version = \".*\"/version = \"${{ steps.release_info.outputs.version }}\"/" Cargo.toml

- name: Update Workspace Dependencies
run: |
cargo update

- name: Create RC Branch
id: rc_branch
run: |
RC_BRANCH="rc/rs/v${{ steps.release_info.outputs.version }}"
git config --global user.name "$GITHUB_USER_NAME"
git config --global user.email "$GITHUB_USER_EMAIL"
git checkout -b "$RC_BRANCH"
git push origin "$RC_BRANCH"
echo "branch=$RC_BRANCH" >> $GITHUB_OUTPUT

- name: Set Workspace Version & Update Its Dependencies
run: |
sed -i "s/^version = \".*\"/version = \"${{ steps.release_info.outputs.version }}\"/" Cargo.toml
cargo update
git add Cargo.toml
git add Cargo.lock
git commit -m "build(rs): update version to v${{ steps.release_info.outputs.version }}"
git push origin "$RC_BRANCH"
git push origin --delete "${{ steps.release_info.outputs.pin_tag }}"
echo "branch=$RC_BRANCH" >> $GITHUB_OUTPUT
git push origin "${{ steps.rc_branch.outputs.branch }}"

ws_tests:
name: Run Workspace Tests
Expand All @@ -94,7 +90,7 @@ jobs:
uses: ./.github/workflows/rs-run-ws-tests.yml
with:
sources_ref: ${{ needs.prepare.outputs.rc_branch }}
gear_node_version: 1.6.0
gear_node_version: 1.7.0

cli_tests:
name: Run CLI Tests
Expand Down Expand Up @@ -175,6 +171,7 @@ jobs:
for SAILS_CRATE in $SAILS_CRATES; do
cargo publish -p $SAILS_CRATE
done
# Revert temporary changes to Cargo.toml
git checkout -- .

- name: Update Contract Template
Expand Down Expand Up @@ -225,11 +222,12 @@ jobs:
name: sails-assets
path: ./assets

- name: Create Release Tag
- name: Re-create Release Tag
run: |
R_TAG=${{ needs.prepare.outputs.r_tag }}
git config --global user.name "$GITHUB_USER_NAME"
git config --global user.email "$GITHUB_USER_EMAIL"
git push origin --delete "$R_TAG"
git tag -a "$R_TAG" -m "Release v${{ needs.prepare.outputs.r_version }}"
git push origin "$R_TAG"

Expand Down
Loading