-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add release pipeline and harden Dockerfile #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e241764
feat: add release pipeline and harden Dockerfile
vrdc-sap 0292c81
harden release workflow against shell injection and tag race condition
vrdc-sap 8695ac7
replace heredoc with echo block to fix YAML syntax error
vrdc-sap d479c13
tighten release workflow validation and action versions
vrdc-sap 9cf9b16
build and verify image before pushing release tag
vrdc-sap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| name: GPU Build Image | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| tags: | ||
| - "[0-9]*" | ||
|
|
||
| permissions: | ||
| id-token: write # Required for requesting the JWT token | ||
| contents: read # Required for actions/checkout | ||
|
|
||
| jobs: | ||
| build-image: | ||
| uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main | ||
| with: | ||
| tags: ${{ github.ref_name }} | ||
| name: gpu | ||
| dockerfile: Dockerfile | ||
| export-tags: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| name: GPU Build Image PR | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, synchronize, reopened, ready_for_review, labeled] | ||
| paths-ignore: | ||
| - .github/workflows/stale.yml | ||
| - docs/** | ||
|
|
||
| permissions: | ||
| id-token: write # Required for requesting the JWT token | ||
| contents: read # Required for actions/checkout | ||
|
|
||
| jobs: | ||
| approve-image-build: | ||
| if: ${{ contains(github.event.pull_request.labels.*.name, 'pr-build-image') }} | ||
| environment: pr-image-build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo "Build approved" | ||
|
|
||
| build-image: | ||
| needs: approve-image-build | ||
| uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main | ||
| with: | ||
| name: gpu | ||
| dockerfile: Dockerfile | ||
| export-tags: true | ||
|
|
||
| local-build: | ||
| name: Build Image Locally | ||
| if: ${{ !contains(github.event.pull_request.labels.*.name, 'pr-build-image') }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout PR head | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
|
vrdc-sap marked this conversation as resolved.
|
||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build Image Locally | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| outputs: type=cacheonly | ||
| push: false | ||
| tags: gpu:${{ github.event.pull_request.head.sha }} | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: "Version to release - bare semver without 'v' (e.g. 0.1.0)" | ||
| required: true | ||
| type: string | ||
| ref: | ||
| description: "Branch, tag, or SHA to release from" | ||
| required: true | ||
| default: "main" | ||
| type: string | ||
|
|
||
| concurrency: | ||
| group: release-${{ inputs.version }} | ||
| cancel-in-progress: false | ||
|
|
||
| env: | ||
| IMAGE: europe-docker.pkg.dev/kyma-project/prod/gpu | ||
|
|
||
| jobs: | ||
| validate: | ||
| name: Validate | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ inputs.ref }} | ||
|
|
||
| - name: Check version format | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| run: | | ||
| if ! echo "${VERSION}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then | ||
| echo "::error::version must be bare semver (e.g. 0.1.0 or 0.1.0-rc.1) - got '${VERSION}'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Check tag does not already exist | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| run: | | ||
| if git ls-remote --quiet --exit-code origin "refs/tags/${VERSION}" >/dev/null; then | ||
| echo "::error::tag ${VERSION} already exists" | ||
| exit 1 | ||
| fi | ||
|
|
||
| build-image: | ||
| name: Build Image | ||
| needs: validate | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main | ||
| with: | ||
| name: gpu | ||
| dockerfile: Dockerfile | ||
| context: . | ||
| tags: ${{ inputs.version }} | ||
|
|
||
| test: | ||
| name: Test | ||
| needs: validate | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ inputs.ref }} | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Build | ||
| run: make build | ||
|
|
||
| - name: Test | ||
| run: make test | ||
|
|
||
| create-tag: | ||
|
vrdc-sap marked this conversation as resolved.
|
||
| name: Create Tag | ||
| needs: [build-image, test] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ inputs.ref }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Configure git identity | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Create and push annotated tag | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| run: | | ||
| git tag -a "${VERSION}" -m "Release ${VERSION}" | ||
| git push origin "${VERSION}" | ||
|
|
||
| publish-release: | ||
| name: Publish Release | ||
| needs: create-tag | ||
|
vrdc-sap marked this conversation as resolved.
|
||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ inputs.ref }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Render install.yaml | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| run: | | ||
| make build-installer IMG=${IMAGE}:${VERSION} | ||
|
|
||
| - name: Generate release notes | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| REPOSITORY: ${{ github.repository }} | ||
| run: | | ||
| PREV_TAG=$(git describe --tags --abbrev=0 "${VERSION}^" 2>/dev/null || echo "") | ||
| if [ -n "$PREV_TAG" ]; then | ||
| CHANGES=$(git log "${PREV_TAG}..${VERSION}" \ | ||
| --pretty=format:"- %s (%h)" --no-merges) | ||
| else | ||
| CHANGES=$(git log --pretty=format:"- %s (%h)" --no-merges) | ||
| fi | ||
| { | ||
| echo "## Changes" | ||
| echo "" | ||
| echo "${CHANGES}" | ||
| echo "" | ||
| echo "## Installation" | ||
| echo "" | ||
| echo '```bash' | ||
| echo "# Install the GPU operator (CRD, RBAC, and controller)" | ||
| echo "kubectl apply -f https://github.com/${REPOSITORY}/releases/download/${VERSION}/install.yaml" | ||
| echo "" | ||
| echo "# Create a Gpu resource to enable GPU support on your cluster" | ||
| echo "kubectl apply -f https://github.com/${REPOSITORY}/releases/download/${VERSION}/instance.yaml" | ||
| echo '```' | ||
| echo "" | ||
| echo "## Image" | ||
| echo "" | ||
| echo "\`${IMAGE}:${VERSION}\`" | ||
| } > /tmp/release-notes.md | ||
|
|
||
| - name: Create GitHub Release | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| VERSION: ${{ inputs.version }} | ||
| run: | | ||
| gh release create "${VERSION}" \ | ||
| --title "${VERSION}" \ | ||
| --notes-file /tmp/release-notes.md \ | ||
| dist/install.yaml \ | ||
| dist/instance.yaml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| module github.com/kyma-project/gpu | ||
|
|
||
| go 1.25.3 | ||
| go 1.26.3 | ||
|
|
||
| require ( | ||
| github.com/Masterminds/semver/v3 v3.4.0 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.