|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + workflow_run: |
| 4 | + workflows: ["Tests"] |
| 5 | + branches: ["master", "main"] |
| 6 | + types: |
| 7 | + - completed |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | +jobs: |
| 11 | + version: |
| 12 | + name: Gather version information |
| 13 | + runs-on: ubuntu-latest |
| 14 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 15 | + outputs: |
| 16 | + latest_version: ${{ steps.latest_version.outputs.version }} |
| 17 | + next_version: ${{ steps.next_version.outputs.version }} |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + - name: Latest version |
| 23 | + id: latest_version |
| 24 | + uses: PSanetra/git-semver-actions/latest@master |
| 25 | + - name: Next version |
| 26 | + id: next_version |
| 27 | + uses: PSanetra/git-semver-actions/next@master |
| 28 | + draft_release: |
| 29 | + name: Release |
| 30 | + needs: version |
| 31 | + if: ${{ needs.version.outputs.latest_version != needs.version.outputs.next_version }} |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + fetch-depth: 0 |
| 37 | + - name: Generate Changelog |
| 38 | + id: generate_changelog |
| 39 | + uses: PSanetra/git-semver-actions/markdown-log@master |
| 40 | + - name: Create Release |
| 41 | + id: create_release |
| 42 | + uses: actions/create-release@v1 |
| 43 | + env: |
| 44 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + with: |
| 46 | + tag_name: v${{ needs.version.outputs.next_version }} |
| 47 | + release_name: Release ${{ needs.version.outputs.next_version }} |
| 48 | + body: | |
| 49 | + ${{ steps.generate_changelog.outputs.changelog }} |
| 50 | + draft: false # Tag must be published before gitreleaser is executed |
| 51 | + prerelease: false |
| 52 | + build_and_publish_artifacts: |
| 53 | + name: Build and publish artifacts |
| 54 | + needs: [version, draft_release] |
| 55 | + if: ${{ needs.version.outputs.latest_version != needs.version.outputs.next_version }} |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + with: |
| 60 | + fetch-depth: 0 |
| 61 | + - uses: docker/setup-qemu-action@v3 |
| 62 | + - uses: docker/setup-buildx-action@v3 |
| 63 | + - uses: docker/login-action@v3 |
| 64 | + name: Login to Docker Hub |
| 65 | + with: |
| 66 | + username: ${{ vars.DOCKER_USERNAME }} |
| 67 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 68 | + - name: Run GoReleaser |
| 69 | + uses: goreleaser/goreleaser-action@v6 |
| 70 | + with: |
| 71 | + distribution: goreleaser |
| 72 | + version: '~> v2' |
| 73 | + args: release --clean |
| 74 | + env: |
| 75 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments