Cut a new release automatically each month #14
Workflow file for this run
This file contains hidden or 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
| name: Automated Release | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| # schedule: | |
| # # Runs at 2:00 AM UTC on the first Saturday of every month | |
| # - cron: '0 2 * * 6' | |
| # workflow_dispatch: # Allow manual triggering of the workflow | |
| jobs: | |
| check-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup GitHub CLI | |
| run: | | |
| gh auth setup-git | |
| gh auth status | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check for Blocking Issues/PRs | |
| id: check_blocks | |
| run: | | |
| echo "Checking for blocking issues and PRs..." | |
| # Check for blocking issues | |
| blocking_issues=$(gh issue list -l blocks-release --json number,title --jq '.[] | "- \(.title) (#\(.number))"') | |
| # Check for blocking PRs | |
| blocking_prs=$(gh pr list -l blocks-release --json number,title --jq '.[] | "- \(.title) (#\(.number)) (PR)"') | |
| # Combine the results | |
| blocking_items="$blocking_issues"$'\n'"$blocking_prs" | |
| # Remove empty lines | |
| blocking_items=$(echo "$blocking_items" | grep . || true) | |
| if [ -n "$blocking_items" ]; then | |
| echo "block_release=true" >> $GITHUB_OUTPUT | |
| echo "blocking_items<<EOF" >> $GITHUB_OUTPUT | |
| echo "$blocking_items" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| else | |
| echo "block_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Stop if Blocks Exist | |
| if: steps.check_blocks.outputs.block_release == 'true' | |
| run: | | |
| echo "Blocking issues/PRs detected:" | |
| echo "${{ steps.check_blocks.outputs.blocking_items }}" | |
| exit 1 | |
| # - name: Check for changes since last release | |
| # run: | | |
| # if [ -z "$(git diff --name-only ${{ env.latest_tag }})" ]; then | |
| # echo "No changes detected since last release" | |
| # exit 1 | |
| # fi | |
| - name: Get Latest Tag | |
| id: get_latest_tag | |
| run: | | |
| latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1) || echo "v0.0.0") | |
| echo "Latest tag: $latest_tag" | |
| echo "latest_tag=$latest_tag" >> $GITHUB_ENV | |
| - name: Bump Version | |
| id: bump_version | |
| run: | | |
| IFS='.' read -r major minor patch <<< "${{ env.latest_tag }}" | |
| new_minor=$((minor + 1)) | |
| new_tag="$major.$new_minor.0" | |
| echo "New tag: $new_tag" | |
| echo "new_tag=$new_tag" >> $GITHUB_ENV | |
| # - name: Push New Tag | |
| # run: | | |
| # git config user.name "github-actions[bot]" | |
| # git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # git tag example-${{ env.new_tag }} | |
| # git push origin example-${{ env.new_tag }} | |
| # env: | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |