|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Version to release - bare semver without 'v' (e.g. 0.1.0)" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + ref: |
| 11 | + description: "Branch, tag, or SHA to release from" |
| 12 | + required: true |
| 13 | + default: "main" |
| 14 | + type: string |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: release-${{ inputs.version }} |
| 18 | + cancel-in-progress: false |
| 19 | + |
| 20 | +env: |
| 21 | + IMAGE: europe-docker.pkg.dev/kyma-project/prod/gpu |
| 22 | + |
| 23 | +jobs: |
| 24 | + validate: |
| 25 | + name: Validate |
| 26 | + runs-on: ubuntu-latest |
| 27 | + permissions: |
| 28 | + contents: read |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v6 |
| 32 | + with: |
| 33 | + ref: ${{ inputs.ref }} |
| 34 | + |
| 35 | + - name: Check version format |
| 36 | + env: |
| 37 | + VERSION: ${{ inputs.version }} |
| 38 | + run: | |
| 39 | + if ! echo "${VERSION}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then |
| 40 | + echo "::error::version must be bare semver (e.g. 0.1.0 or 0.1.0-rc.1) - got '${VERSION}'" |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Check tag does not already exist |
| 45 | + env: |
| 46 | + VERSION: ${{ inputs.version }} |
| 47 | + run: | |
| 48 | + if git ls-remote --quiet --exit-code origin "refs/tags/${VERSION}" >/dev/null; then |
| 49 | + echo "::error::tag ${VERSION} already exists" |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | +
|
| 53 | + build-image: |
| 54 | + name: Build Image |
| 55 | + needs: validate |
| 56 | + permissions: |
| 57 | + id-token: write |
| 58 | + contents: read |
| 59 | + uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main |
| 60 | + with: |
| 61 | + name: gpu |
| 62 | + dockerfile: Dockerfile |
| 63 | + context: . |
| 64 | + tags: ${{ inputs.version }} |
| 65 | + |
| 66 | + test: |
| 67 | + name: Test |
| 68 | + needs: validate |
| 69 | + runs-on: ubuntu-latest |
| 70 | + permissions: |
| 71 | + contents: read |
| 72 | + steps: |
| 73 | + - name: Checkout |
| 74 | + uses: actions/checkout@v6 |
| 75 | + with: |
| 76 | + ref: ${{ inputs.ref }} |
| 77 | + |
| 78 | + - name: Setup Go |
| 79 | + uses: actions/setup-go@v6 |
| 80 | + with: |
| 81 | + go-version-file: go.mod |
| 82 | + |
| 83 | + - name: Build |
| 84 | + run: make build |
| 85 | + |
| 86 | + - name: Test |
| 87 | + run: make test |
| 88 | + |
| 89 | + create-tag: |
| 90 | + name: Create Tag |
| 91 | + needs: [build-image, test] |
| 92 | + runs-on: ubuntu-latest |
| 93 | + permissions: |
| 94 | + contents: write |
| 95 | + steps: |
| 96 | + - name: Checkout |
| 97 | + uses: actions/checkout@v6 |
| 98 | + with: |
| 99 | + ref: ${{ inputs.ref }} |
| 100 | + fetch-depth: 0 |
| 101 | + |
| 102 | + - name: Configure git identity |
| 103 | + run: | |
| 104 | + git config user.name "github-actions[bot]" |
| 105 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 106 | +
|
| 107 | + - name: Create and push annotated tag |
| 108 | + env: |
| 109 | + VERSION: ${{ inputs.version }} |
| 110 | + run: | |
| 111 | + git tag -a "${VERSION}" -m "Release ${VERSION}" |
| 112 | + git push origin "${VERSION}" |
| 113 | +
|
| 114 | + publish-release: |
| 115 | + name: Publish Release |
| 116 | + needs: create-tag |
| 117 | + runs-on: ubuntu-latest |
| 118 | + permissions: |
| 119 | + contents: write |
| 120 | + steps: |
| 121 | + - name: Checkout |
| 122 | + uses: actions/checkout@v6 |
| 123 | + with: |
| 124 | + ref: ${{ inputs.ref }} |
| 125 | + fetch-depth: 0 |
| 126 | + |
| 127 | + - name: Setup Go |
| 128 | + uses: actions/setup-go@v6 |
| 129 | + with: |
| 130 | + go-version-file: go.mod |
| 131 | + |
| 132 | + - name: Render install.yaml |
| 133 | + env: |
| 134 | + VERSION: ${{ inputs.version }} |
| 135 | + run: | |
| 136 | + make build-installer IMG=${IMAGE}:${VERSION} |
| 137 | +
|
| 138 | + - name: Generate release notes |
| 139 | + env: |
| 140 | + VERSION: ${{ inputs.version }} |
| 141 | + REPOSITORY: ${{ github.repository }} |
| 142 | + run: | |
| 143 | + PREV_TAG=$(git describe --tags --abbrev=0 "${VERSION}^" 2>/dev/null || echo "") |
| 144 | + if [ -n "$PREV_TAG" ]; then |
| 145 | + CHANGES=$(git log "${PREV_TAG}..${VERSION}" \ |
| 146 | + --pretty=format:"- %s (%h)" --no-merges) |
| 147 | + else |
| 148 | + CHANGES=$(git log --pretty=format:"- %s (%h)" --no-merges) |
| 149 | + fi |
| 150 | + { |
| 151 | + echo "## Changes" |
| 152 | + echo "" |
| 153 | + echo "${CHANGES}" |
| 154 | + echo "" |
| 155 | + echo "## Installation" |
| 156 | + echo "" |
| 157 | + echo '```bash' |
| 158 | + echo "# Install the GPU operator (CRD, RBAC, and controller)" |
| 159 | + echo "kubectl apply -f https://github.com/${REPOSITORY}/releases/download/${VERSION}/install.yaml" |
| 160 | + echo "" |
| 161 | + echo "# Create a Gpu resource to enable GPU support on your cluster" |
| 162 | + echo "kubectl apply -f https://github.com/${REPOSITORY}/releases/download/${VERSION}/instance.yaml" |
| 163 | + echo '```' |
| 164 | + echo "" |
| 165 | + echo "## Image" |
| 166 | + echo "" |
| 167 | + echo "\`${IMAGE}:${VERSION}\`" |
| 168 | + } > /tmp/release-notes.md |
| 169 | +
|
| 170 | + - name: Create GitHub Release |
| 171 | + env: |
| 172 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 173 | + VERSION: ${{ inputs.version }} |
| 174 | + run: | |
| 175 | + gh release create "${VERSION}" \ |
| 176 | + --title "${VERSION}" \ |
| 177 | + --notes-file /tmp/release-notes.md \ |
| 178 | + dist/install.yaml \ |
| 179 | + dist/instance.yaml |
0 commit comments