Skip to content

Commit

Permalink
ci: refine the scheduled bump run, remove on push
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef committed Mar 13, 2024
1 parent 13e22ad commit 2164b3c
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions .github/workflows/version_bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,21 @@ name: Version Bump

# prevent concurrent version bumps
concurrency:
group: "version-bump-${{ github.event_name == 'schedule' && 'alpha' || github.ref_name }}"
group: "version-bump-${{ github.event_name == 'schedule' && 'main' || github.ref_name }}"

on:
push:
branches:
# run for everything that gets into main
# - main
# - beta

# schedule:
# # Schedule for midnight UTC. Adjust according to your timezone
# - cron: "0 0 * * *" # Runs at 00:00 UTC every day
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:
# for pushes, we dont run on alpha
# for schedules, we only run on alpha
# and if its maidsafe and not already a release commit.
# only run if its maidsafe repo and not already a release commit.
if: >
(github.event_name == 'schedule' && github.ref_name == 'alpha') ||
github.repository_owner == 'maidsafe' &&
!startsWith(github.event.head_commit.message, 'chore(release):')
runs-on: ubuntu-22.04
Expand All @@ -36,8 +27,8 @@ jobs:
with:
fetch-depth: "0"
token: ${{ secrets.VERSION_BUMP_COMMIT_PAT }}
# For scheduled runs, explicitly set ref to 'alpha'. Otherwise, use the triggering ref.
ref: ${{ github.event_name == 'schedule' && 'alpha' || github.ref_name }}
# 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
Expand All @@ -54,11 +45,11 @@ jobs:
repository-name: ${{ github.repository }}
repository-owner: ${{ github.repository_owner }}
head-sha: ${{ env.sha }}
base-branch: ${{ github.event_name == 'schedule' && 'alpha' || github.ref_name }}
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' && 'alpha' || github.ref_name }}
run: git pull origin ${{ github.event_name == 'schedule' && 'main' || github.ref_name }}

- uses: actions-rs/toolchain@v1
with:
Expand All @@ -84,12 +75,13 @@ jobs:
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' && 'alpha' || github.ref_name }}
branch: ${{ github.event_name == 'schedule' && 'main' || github.ref_name }}
tags: true
- name: post notification to slack on failure
if: ${{ failure() }}
Expand Down

0 comments on commit 2164b3c

Please sign in to comment.