|
7 | 7 | pull_request: |
8 | 8 | branches: [ main, master ] |
9 | 9 |
|
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + actions: read |
| 13 | + security-events: write |
| 14 | + |
10 | 15 | jobs: |
11 | 16 | test: |
12 | 17 | runs-on: ubuntu-latest |
@@ -36,57 +41,13 @@ jobs: |
36 | 41 | - name: Run staticcheck |
37 | 42 | run: staticcheck ./... |
38 | 43 |
|
39 | | - auto-update-version: |
40 | | - needs: test |
41 | | - runs-on: ubuntu-latest |
42 | | - if: startsWith(github.ref, 'refs/tags/') |
43 | | - |
44 | | - steps: |
45 | | - - uses: actions/checkout@v4 |
46 | | - with: |
47 | | - token: ${{ secrets.GITHUB_TOKEN }} |
48 | | - fetch-depth: 0 |
49 | | - |
50 | | - - name: Get version |
51 | | - id: version |
52 | | - run: | |
53 | | - VERSION=${GITHUB_REF#refs/tags/v} |
54 | | - echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
55 | | - echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
56 | | - |
57 | | - - name: Update version in files |
58 | | - run: | |
59 | | - VERSION="${{ steps.version.outputs.VERSION }}" |
60 | | - |
61 | | - # Update main.go |
62 | | - sed -i "s/Version = \".*\"/Version = \"$VERSION\"/" main.go |
63 | | - |
64 | | - # Update build-release.sh |
65 | | - sed -i "s/VERSION=\".*\"/VERSION=\"$VERSION\"/" build-release.sh |
66 | | - |
67 | | - # Update install.sh |
68 | | - sed -i "s/VERSION=\".*\"/VERSION=\"$VERSION\"/" install.sh |
69 | | - |
70 | | - echo "Updated version to $VERSION in all files" |
71 | | - |
72 | | - - name: Commit version updates |
73 | | - run: | |
74 | | - git config --local user.email "[email protected]" |
75 | | - git config --local user.name "GitHub Action" |
76 | | - git add main.go build-release.sh install.sh |
77 | | - git diff --staged --quiet || git commit -m "chore: auto-update version to ${{ steps.version.outputs.VERSION }}" |
78 | | - git push origin HEAD:main |
79 | | - continue-on-error: true |
80 | | - |
81 | 44 | build: |
82 | | - needs: [test, auto-update-version] |
| 45 | + needs: test |
83 | 46 | runs-on: ubuntu-latest |
84 | 47 | if: startsWith(github.ref, 'refs/tags/') |
85 | 48 |
|
86 | 49 | steps: |
87 | 50 | - uses: actions/checkout@v4 |
88 | | - with: |
89 | | - ref: main # Get the updated files from auto-update-version job |
90 | 51 |
|
91 | 52 | - name: Set up Go |
92 | 53 | uses: actions/setup-go@v4 |
|
106 | 67 | ./build-release.sh |
107 | 68 | |
108 | 69 | - name: Create Release |
109 | | - uses: softprops/action-gh-release@v1 |
| 70 | + uses: softprops/action-gh-release@v2 |
110 | 71 | with: |
111 | 72 | files: | |
112 | 73 | dist/*.tar.gz |
@@ -164,5 +125,4 @@ jobs: |
164 | 125 | sha256sum -c checksums.txt |
165 | 126 | ``` |
166 | 127 | generate_release_notes: true |
167 | | - env: |
168 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 128 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments