Version Bump #219
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically run the versino bump script. | |
# We do this only on main/beta branches, and only if the commit message doesn't start with 'chore(release):' | |
name: Version Bump | |
# prevent concurrent version bumps | |
concurrency: | |
group: "version-bump-${{ github.event_name == 'schedule' && 'main' || github.ref_name }}" | |
on: | |
schedule: | |
# Schedule for midnight UTC. Adjust according to your timezone | |
- cron: "0 0 * * *" # Runs at 00:00 UTC every day | |
env: | |
RELEASE_PLZ_BIN_URL: https://github.com/MarcoIeni/release-plz/releases/download/release-plz-v0.3.43/release-plz-x86_64-unknown-linux-gnu.tar.gz | |
WORKFLOW_URL: https://github.com/maidsafe/safe_network/actions/runs | |
jobs: | |
bump_version: | |
# only run if its maidsafe repo and not already a release commit. | |
if: > | |
github.repository_owner == 'maidsafe' && | |
!startsWith(github.event.head_commit.message, 'chore(release):') | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: "0" | |
token: ${{ secrets.VERSION_BUMP_COMMIT_PAT }} | |
# For scheduled runs, explicitly set ref to 'main'. Otherwise, use the triggering ref. | |
ref: ${{ github.event_name == 'schedule' && 'main' || github.ref_name }} | |
- name: Get the SHA of the last release commit | |
id: get-sha | |
run: echo "sha=$(git log --grep='chore(release):' -n 1 --pretty=format:"%H")" >> $GITHUB_ENV | |
- name: Wait for release workflow to complete | |
uses: mostafahussein/[email protected] | |
# Don't fail the whole run if this step fails | |
# this action will fail if the previous workflows failed or was skipped, | |
# which isn't helpful | |
continue-on-error: true | |
with: | |
secret: ${{ secrets.GITHUB_TOKEN }} | |
repository-name: ${{ github.repository }} | |
repository-owner: ${{ github.repository_owner }} | |
head-sha: ${{ env.sha }} | |
base-branch: ${{ github.event_name == 'schedule' && 'main' || github.ref_name }} | |
polling-interval: 60 | |
- name: Fetch the latest code from the specified branch | |
run: git pull origin ${{ github.event_name == 'schedule' && 'main' || github.ref_name }} | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
# install cargo-edit for bump script, this makes it simpler to bump into workspaces | |
- name: Install cargo-edit with vendored-openssl | |
run: cargo install cargo-edit --features vendored-openssl | |
- shell: bash | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
# It's possible to `cargo install` release-plz, but it's very slow to compile on GHA infra. | |
# Therefore we just pull the binary from the Github Release. | |
- name: install release-plz | |
shell: bash | |
run: | | |
curl -L -O $RELEASE_PLZ_BIN_URL | |
tar xvf release-plz-x86_64-unknown-linux-gnu.tar.gz | |
rm release-plz-x86_64-unknown-linux-gnu.tar.gz | |
sudo mv release-plz /usr/local/bin | |
- shell: bash | |
# run an alpha release bump when scheduled, otherwise run as the branch name | |
run: ./resources/scripts/bump_version.sh ${{ github.event_name == 'schedule' && 'alpha' || github.ref_name }} | |
- name: push version bump commit | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.VERSION_BUMP_COMMIT_PAT }} | |
branch: ${{ github.event_name == 'schedule' && 'main' || github.ref_name }} | |
tags: true | |
- name: post notification to slack on failure | |
if: ${{ failure() }} | |
uses: bryannice/[email protected] | |
env: | |
SLACK_INCOMING_WEBHOOK: ${{ secrets.SLACK_GH_ACTIONS_WEBHOOK_URL }} | |
SLACK_MESSAGE: "Please check the logs for the run at ${{ env.WORKFLOW_URL }}/${{ github.run_id }}" | |
SLACK_TITLE: "Version Bumping Failed" |