|
| 1 | +name: Release module |
| 2 | + |
| 3 | +# Controls when the action will run. Triggers the workflow on push or pull request |
| 4 | +# events but only for the main branch |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + |
| 10 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + # Drafts your next Release notes as Pull Requests are merged into "main" |
| 20 | + - name: Create release |
| 21 | + id: create-release |
| 22 | + uses: release-drafter/release-drafter@v6 |
| 23 | + with: |
| 24 | + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml |
| 25 | + config-name: release-drafter.yaml |
| 26 | + publish: false |
| 27 | + prerelease: false |
| 28 | + env: |
| 29 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + |
| 31 | + - name: Set up Go |
| 32 | + uses: actions/setup-go@v5 |
| 33 | + with: |
| 34 | + go-version: '^1.24.5' # The Go version to download (if necessary) and use. |
| 35 | + |
| 36 | + - name: Update version |
| 37 | + run: | |
| 38 | + TAG_NAME=$(echo "${{ steps.create-release.outputs.tag_name }}" | sed "s/v//g") |
| 39 | + cat Makefile | sed "s/^VERSION .*/VERSION ?= ${TAG_NAME}/g" > /tmp/Makefile |
| 40 | + diff Makefile /tmp/Makefile && echo "" || echo "" |
| 41 | + cp /tmp/Makefile Makefile |
| 42 | + |
| 43 | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 44 | + git config --local user.name "github-actions[bot]" |
| 45 | + |
| 46 | + git add -u |
| 47 | + |
| 48 | + git commit -m "Update version to ${TAG_NAME} Makefile" |
| 49 | +
|
| 50 | + - name: Push changes |
| 51 | + uses: ad-m/github-push-action@master |
| 52 | + with: |
| 53 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + |
| 55 | + - name: Publish release |
| 56 | + id: publish-release |
| 57 | + uses: eregon/publish-release@v1 |
| 58 | + env: |
| 59 | + GITHUB_TOKEN: ${{ secrets.TOKEN }} |
| 60 | + with: |
| 61 | + release_id: ${{ steps.create-release.outputs.id }} |
0 commit comments