|
| 1 | +name: Automated Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + # schedule: |
| 9 | + # # Runs at 2:00 AM UTC on the first Saturday of every month |
| 10 | + # - cron: '0 2 * * 6' |
| 11 | + # workflow_dispatch: # Allow manual triggering of the workflow |
| 12 | + |
| 13 | +jobs: |
| 14 | + check-and-release: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout Code |
| 19 | + uses: actions/checkout@v3 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Check for Blocking Issues/PRs |
| 24 | + id: check_blocks |
| 25 | + uses: actions/github-script@v6 |
| 26 | + with: |
| 27 | + script: | |
| 28 | + const { data: issues } = await github.rest.issues.listForRepo({ |
| 29 | + owner: context.repo.owner, |
| 30 | + repo: context.repo.repo, |
| 31 | + labels: 'blocks-release', |
| 32 | + state: 'open' |
| 33 | + }); |
| 34 | + if (issues.length > 0) { |
| 35 | + core.setOutput('block_release', 'true'); |
| 36 | + core.setOutput('blocking_items', issues.map(issue => `- ${issue.title} (#${issue.number})`).join("\n")); |
| 37 | + } else { |
| 38 | + core.setOutput('block_release', 'false'); |
| 39 | + } |
| 40 | +
|
| 41 | + - name: Stop if Blocks Exist |
| 42 | + if: steps.check-blocks.outputs.block_release == 'true' |
| 43 | + run: | |
| 44 | + echo "Blocking issues/PRs detected:" |
| 45 | + echo "${{ steps.check-blocks.outputs.blocking_items }}" |
| 46 | + exit 1 |
| 47 | +
|
| 48 | + # - name: Check for changes since last release |
| 49 | + # run: | |
| 50 | + # if [ -z "$(git diff --name-only ${{ env.latest_tag }})" ]; then |
| 51 | + # echo "No changes detected since last release" |
| 52 | + # exit 1 |
| 53 | + # fi |
| 54 | + |
| 55 | + - name: Get Latest Tag |
| 56 | + id: get_latest_tag |
| 57 | + run: | |
| 58 | + latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1) || echo "v0.0.0") |
| 59 | + echo "Latest tag: $latest_tag" |
| 60 | + echo "latest_tag=$latest_tag" >> $GITHUB_ENV |
| 61 | +
|
| 62 | + - name: Bump Version |
| 63 | + id: bump_version |
| 64 | + run: | |
| 65 | + IFS='.' read -r major minor patch <<< "${{ env.latest_tag }}" |
| 66 | + new_minor=$((minor + 1)) |
| 67 | + new_tag="$major.$new_minor.0" |
| 68 | + echo "New tag: $new_tag" |
| 69 | + echo "new_tag=$new_tag" >> $GITHUB_ENV |
| 70 | +
|
| 71 | + # - name: Push New Tag |
| 72 | + # run: | |
| 73 | + # git config user.name "github-actions[bot]" |
| 74 | + # git config user.email "github-actions[bot]@users.noreply.github.com" |
| 75 | + # git tag ${{ env.new_tag }} |
| 76 | + # git push origin ${{ env.new_tag }} |
| 77 | + # env: |
| 78 | + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments