Skip to content

scheduled-releases

scheduled-releases #12

name: scheduled-releases
on:
schedule:
# Runs every Wednesday at 08:00 UTC (midnight PST / 1:00 AM PDT)
- cron: '0 8 * * 3'
# Allows manual triggering for convenience
workflow_dispatch:
jobs:
tag-weekly-release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
commit_range_start: ${{ steps.range.outputs.commit_range_start }}
commit_range_end: ${{ steps.range.outputs.commit_range_end }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Use a token with write permissions to push to the branch
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # Fetch all history for merging
- name: Configure Git
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Create tag
id: create-tag
run: |
# Date in the format YYMMDD
TAG="release/weekly/$(date +%y%m%d)"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
echo "TAG=$TAG" >> $GITHUB_OUTPUT
- name: Determine commit range
id: range
run: |
# New tag we just created
NEW_TAG=${{ steps.create-tag.outputs.TAG }}
# Find the previous tag (sorted newest‑first)
PREV_TAG=$(git tag --list "release/weekly/*" --sort=-creatordate | sed -n '2p')
# If we’re on the very first tag, fall back to main
if [ -z "$PREV_TAG" ]; then
PREV_TAG=main
fi
# Resolve the commit hashes
START_COMMIT=$(git rev-parse "$PREV_TAG")
END_COMMIT=$(git rev-parse "$NEW_TAG")
# Export them as workflow outputs
echo "commit_range_start=$START_COMMIT" >> $GITHUB_OUTPUT
echo "commit_range_end=$END_COMMIT" >> $GITHUB_OUTPUT
# Then trigger the build workflow with the commit range.
trigger-build:
needs: tag-weekly-release
uses: ./.github/workflows/build.yml
with:
commit_range_start: ${{ needs.tag-weekly-release.outputs.commit_range_start }}
commit_range_end: ${{ needs.tag-weekly-release.outputs.commit_range_end }}
is_scheduled: true
secrets: inherit