summaryrefslogtreecommitdiff
path: root/.github/workflows/generate_release.yml
blob: 980f95c949fd45a6035469f03a85664ffe706d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Generate Release

on:
  workflow_call:
    inputs:
      handwritten:
        required: false
        type: string
      release_tag:
        required: true
        type: string
  workflow_dispatch:
    inputs:
      handwritten:
        description: 'Small changelog about changes in this build'
        required: false
        type: string
      release_tag:
        required: true
        type: string

permissions: {}

jobs:
  generate-release:
    runs-on: ubuntu-24.04
    permissions:
      contents: write
      packages: read


    steps:
      - uses: actions/checkout@v7.0.1
        with:
          fetch-depth: 0

      - name: Install ORAS
        uses: oras-project/setup-oras@005458ad77f1c8facd38a094e4af2e69e5607ff4 # v2.0.2

      - name: Log in to GHCR
        uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Log in to GHCR with ORAS
        env:
          GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: echo "${GHCR_TOKEN}" | oras login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin

      - name: Align release tag with build commit
        env:
          RELEASE_TAG: ${{ inputs.release_tag }}
        run: |
          set -euo pipefail

          git tag --force "${RELEASE_TAG}" "${GITHUB_SHA}"
          git push --force origin "refs/tags/${RELEASE_TAG}"
          echo "Release tag ${RELEASE_TAG} now points to ${GITHUB_SHA}."

      - name: Determine release channel
        id: target
        run: |
          target="${GITHUB_REF_NAME}"
          [[ "${target}" == "main" ]] && target="stable"
          echo "target=${target}" >> "$GITHUB_OUTPUT"

      - name: Generate package and commit changelog
        env:
          IMAGE: ghcr.io/${{ github.repository }}
          RELEASE_TAG: ${{ inputs.release_tag }}
          HANDWRITTEN: ${{ inputs.handwritten }}
        run: |
          python3 .github/scripts/generate_changelog.py \
            --image "${IMAGE,,}" \
            --repository "${GITHUB_REPOSITORY}" \
            --current "${RELEASE_TAG}" \
            --channel "${{ steps.target.outputs.target }}" \
            --handwritten "${HANDWRITTEN}" \
            --output release-notes.md

      - name: Generate release
        uses: softprops/action-gh-release@v3.0.3
        with:
          tag_name: "${{ inputs.release_tag }}"
          name: "${{ inputs.release_tag }}"
          body_path: release-notes.md
          prerelease: ${{ steps.target.outputs.target != 'stable' }}
          make_latest: ${{ steps.target.outputs.target == 'stable' }}