|
1 |
| -name: Automated Release |
| 1 | +name: Release |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | schedule:
|
5 | 5 | # Runs at 2:00 AM UTC on the first Saturday of every month
|
6 | 6 | - cron: '0 2 1-7 * 6'
|
7 |
| - workflow_dispatch: # Allow manual triggering of the workflow |
| 7 | + # Allow manual triggering of the workflow |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + version_bump: |
| 11 | + description: 'Version bump type' |
| 12 | + type: choice |
| 13 | + required: true |
| 14 | + default: 'patch' |
| 15 | + options: |
| 16 | + - minor |
| 17 | + - patch |
| 18 | + ignore_blocks: |
| 19 | + description: 'Ignore blocking PRs/issues' |
| 20 | + type: boolean |
| 21 | + required: true |
| 22 | + default: false |
8 | 23 |
|
9 | 24 | jobs:
|
10 | 25 | check-and-release:
|
11 | 26 | runs-on: ubuntu-latest
|
12 |
| - |
13 | 27 | steps:
|
14 | 28 | - name: Checkout Code
|
15 |
| - uses: actions/checkout@v3 |
| 29 | + uses: actions/checkout@v4 |
16 | 30 | with:
|
17 | 31 | fetch-depth: 0
|
18 | 32 |
|
|
30 | 44 | fi
|
31 | 45 |
|
32 | 46 | - name: Check for Blocking Issues/PRs
|
| 47 | + if: ${{ !inputs.ignore_blocks }} |
33 | 48 | id: check_blocks
|
34 | 49 | run: |
|
35 | 50 | gh auth setup-git
|
@@ -60,18 +75,51 @@ jobs:
|
60 | 75 | - name: Calculate next version
|
61 | 76 | run: |
|
62 | 77 | echo "Latest tag: ${{ env.latest_tag }}"
|
63 |
| - IFS='.' read -r major minor patch <<< "${{ env.latest_tag }}" |
64 |
| - new_minor=$((minor + 1)) |
65 |
| - new_tag="$major.$new_minor.0" |
| 78 | + IFS='.' read -r major minor patch <<< "${env.latest_tag#v}" |
| 79 | +
|
| 80 | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then |
| 81 | + if [[ "${{ inputs.version_bump }}" == "patch" ]]; then |
| 82 | + patch=$((patch + 1)) |
| 83 | + else |
| 84 | + minor=$((minor + 1)) |
| 85 | + patch=0 |
| 86 | + fi |
| 87 | + else |
| 88 | + # Default behavior for scheduled runs |
| 89 | + minor=$((minor + 1)) |
| 90 | + patch=0 |
| 91 | + fi |
| 92 | +
|
| 93 | + new_tag="v$major.$minor.$patch" |
66 | 94 | echo "New tag: $new_tag"
|
67 | 95 | echo "new_tag=$new_tag" >> $GITHUB_ENV
|
68 | 96 |
|
69 |
| - # This will trigger a deploy via .github/workflows/cd.yml |
70 |
| - - name: Push New Tag |
| 97 | + - name: Create and Push Tag |
71 | 98 | run: |
|
72 | 99 | git config user.name "github-actions[bot]"
|
73 | 100 | git config user.email "github-actions[bot]@users.noreply.github.com"
|
74 | 101 | git tag ${{ env.new_tag }}
|
75 | 102 | git push origin ${{ env.new_tag }}
|
76 | 103 | env:
|
77 | 104 | GITHUB_TOKEN: ${{ secrets.GITHUB_API_TOKEN }}
|
| 105 | + |
| 106 | + - name: Setup Go |
| 107 | + uses: actions/setup-go@v5 |
| 108 | + with: |
| 109 | + go-version: 1.22.x |
| 110 | + |
| 111 | + - name: Run goreleaser |
| 112 | + uses: goreleaser/goreleaser-action@v4 |
| 113 | + with: |
| 114 | + distribution: goreleaser |
| 115 | + version: v1.17.2 |
| 116 | + args: release --clean |
| 117 | + env: |
| 118 | + GITHUB_TOKEN: ${{secrets.GITHUB_API_TOKEN}} |
| 119 | + |
| 120 | + - name: Bump Homebrew formula |
| 121 | + uses: dawidd6/action-homebrew-bump-formula@v3 |
| 122 | + with: |
| 123 | + token: ${{secrets.GITHUB_API_TOKEN}} |
| 124 | + formula: lazygit |
| 125 | + tag: ${{env.new_tag}} |
0 commit comments