|
| 1 | +name: Tag and Release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [closed] |
| 6 | + branches: ['main'] |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + version: ${{ steps.get_tag.outputs.version }} |
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + packages: write |
| 16 | + attestations: write |
| 17 | + id-token: write |
| 18 | + if: startsWith(github.event.pull_request.title, 'Release:') && github.event.pull_request.merged == true |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + |
| 25 | + - name: Setup Git |
| 26 | + run: | |
| 27 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 28 | + git config --local user.name "github-actions[bot]" |
| 29 | +
|
| 30 | + - name: Get tag |
| 31 | + id: get_tag |
| 32 | + run: | |
| 33 | + git pull |
| 34 | + echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT |
| 35 | +
|
| 36 | + - name: Tag the commit |
| 37 | + run: | |
| 38 | + next_version=${{ steps.get_tag.outputs.version }} |
| 39 | + git tag -a "$next_version" -m "Version $next_version" |
| 40 | + git push --follow-tags |
| 41 | +
|
| 42 | + docker-publish-dashboard: |
| 43 | + needs: release |
| 44 | + uses: ./.github/workflows/reusable-docker-publish.yml |
| 45 | + permissions: |
| 46 | + contents: write |
| 47 | + packages: write |
| 48 | + attestations: write |
| 49 | + id-token: write |
| 50 | + with: |
| 51 | + image_name: ${{ github.repository }}/dashboard |
| 52 | + dockerfile: ./Containerfile.dashboard |
| 53 | + tags: | |
| 54 | + ghcr.io/${{ github.repository }}/dashboard:${{ needs.release.outputs.version }} |
| 55 | + ghcr.io/${{ github.repository }}/dashboard:latest |
| 56 | + secrets: |
| 57 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + |
| 59 | + docker-publish-python: |
| 60 | + needs: release |
| 61 | + uses: ./.github/workflows/reusable-docker-publish.yml |
| 62 | + permissions: |
| 63 | + contents: write |
| 64 | + packages: write |
| 65 | + attestations: write |
| 66 | + id-token: write |
| 67 | + with: |
| 68 | + image_name: ${{ github.repository }}/python |
| 69 | + dockerfile: ./Containerfile.python |
| 70 | + tags: | |
| 71 | + ghcr.io/${{ github.repository }}/python:${{ needs.release.outputs.version }} |
| 72 | + ghcr.io/${{ github.repository }}/python:latest |
| 73 | + secrets: |
| 74 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + |
| 76 | + create-release: |
| 77 | + needs: [release, docker-publish-dashboard, docker-publish-python] |
| 78 | + runs-on: ubuntu-latest |
| 79 | + permissions: |
| 80 | + contents: write |
| 81 | + steps: |
| 82 | + - name: Checkout code |
| 83 | + uses: actions/checkout@v4 |
| 84 | + |
| 85 | + - name: Create changelog diff |
| 86 | + run: | |
| 87 | + sed -n '/#### \[${{ needs.release.outputs.version }}\]/,/^#### /p' CHANGELOG.md | sed '$d' > release_notes.md |
| 88 | +
|
| 89 | + - name: Create release |
| 90 | + uses: softprops/action-gh-release@v2 |
| 91 | + with: |
| 92 | + tag_name: ${{ needs.release.outputs.version }} |
| 93 | + name: Release ${{ needs.release.outputs.version }} |
| 94 | + body_path: ./release_notes.md |
| 95 | + draft: false |
| 96 | + prerelease: false |
| 97 | + env: |
| 98 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + |
| 100 | + - name: Delete release_notes file |
| 101 | + run: rm release_notes.md |
0 commit comments