-
Notifications
You must be signed in to change notification settings - Fork 12
Create release job #163
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
Create release job #163
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d087fa6
version: add internal version package and startup logging
alicefr dcc8650
build: wire version ldflags into Makefile and Containerfile
alicefr 633cf20
build: add release-manifest target for install.yaml generation
alicefr eecdac1
ci: add release workflow triggered by PR merge
alicefr 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,98 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| release: | ||
| if: >- | ||
| github.event.pull_request.merged == true && | ||
| contains(github.event.pull_request.labels.*.name, 'release') | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| packages: write | ||
| env: | ||
| IMAGE: ghcr.io/${{ github.repository }} | ||
| steps: | ||
| - name: Create GitHub App token | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| id: app-token | ||
| with: | ||
| app-id: ${{ secrets.APP_ID }} | ||
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | ||
| permission-contents: write | ||
|
|
||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Extract version | ||
| id: version | ||
| run: | | ||
| VERSION=$(cat VERSION) | ||
| if ! echo "${VERSION}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then | ||
| echo "::error::Invalid version format: ${VERSION}" | ||
| exit 1 | ||
| fi | ||
| echo "version=${VERSION}" >> "${GITHUB_OUTPUT}" | ||
| echo "tag=v${VERSION}" >> "${GITHUB_OUTPUT}" | ||
|
|
||
| - name: Create and push tag | ||
| env: | ||
| TAG: ${{ steps.version.outputs.tag }} | ||
| APP_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| run: | | ||
| if git rev-parse "${TAG}" >/dev/null 2>&1; then | ||
| echo "::error::Tag ${TAG} already exists" | ||
| exit 1 | ||
| fi | ||
| git tag -a -m "Release ${TAG}" "${TAG}" | ||
| git remote set-url origin "https://x-access-token:${APP_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | ||
| git push origin "${TAG}" | ||
| git remote set-url origin "https://github.com/${GITHUB_REPOSITORY}.git" | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | ||
| with: | ||
| go-version-file: go.mod | ||
| cache: true # zizmor: ignore[cache-poisoning] | ||
|
|
||
| - name: Build and push container image | ||
| env: | ||
| TAG: ${{ steps.version.outputs.tag }} | ||
| ACTOR: ${{ github.actor }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| make buildimg IMG="${IMAGE}:${TAG}" | ||
| podman login -u "${ACTOR}" -p "${GH_TOKEN}" ghcr.io | ||
| podman push "${IMAGE}:${TAG}" | ||
|
|
||
| - name: Build install manifest | ||
| env: | ||
| TAG: ${{ steps.version.outputs.tag }} | ||
| run: make release-manifest IMG="${IMAGE}:${TAG}" | ||
|
|
||
| - name: Create release | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| TAG: ${{ steps.version.outputs.tag }} | ||
| run: | | ||
| { | ||
| printf '## Installation\n\n' | ||
| printf '```bash\n' | ||
| printf 'kubectl apply -f https://github.com/%s/releases/download/%s/install.yaml\n' \ | ||
| "${GITHUB_REPOSITORY}" "${TAG}" | ||
| printf '```\n' | ||
| } > notes.md | ||
| gh release create "${TAG}" \ | ||
| --title "Release ${TAG}" \ | ||
| --notes-file notes.md \ | ||
| --generate-notes \ | ||
| --draft \ | ||
| install.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 0.1.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
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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package version | ||
|
|
||
| var ( | ||
| Version = "dev" | ||
| GitCommit = "unknown" | ||
| ) |
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.