-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,89 @@ | ||
# gitjob release workflow | ||
name: gitjob release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v** | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
id-token: write # this is important, it's how we authenticate with Vault | ||
|
||
env: | ||
GOARCH: amd64 | ||
CGO_ENABLED: 0 | ||
SETUP_K3D_VERSION: 'v5.5.1' | ||
|
||
jobs: | ||
build-gitjob: | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'rancher/gitjob' | ||
steps: | ||
- name: Check out Gitjob | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
check-latest: true | ||
|
||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v6.0.1 | ||
with: | ||
# Required: the version of golangci-lint is required and must be specified without patch version: we always | ||
# use the latest patch version. | ||
version: v1.58 | ||
args: --timeout=10m --config=.golangci.json | ||
|
||
- name: "Read Vault Secrets" | ||
uses: rancher-eio/read-vault-secrets@main | ||
with: | ||
secrets: | | ||
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ; | ||
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD ; | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log into Docker Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ env.DOCKER_USERNAME }} | ||
password: ${{ env.DOCKER_PASSWORD }} | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
id: goreleaser | ||
with: | ||
distribution: goreleaser | ||
version: '~> v2' | ||
args: release --clean --verbose | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload charts to release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
repo: "rancher" | ||
run: | | ||
version=$(echo '${{ steps.goreleaser.outputs.metadata }}' | jq -r '.version') | ||
tag=$(echo '${{ steps.goreleaser.outputs.metadata }}' | jq -r '.tag') | ||
echo "publishing helm chart for (repo: $repo, tag: $tag, version: $version)" | ||
sed -i \ | ||
-e "s/tag:.*/tag: $tag/" \ | ||
charts/values.yaml | ||
helm package --version="$version" --app-version="$version" -d ./dist ./charts | ||
for f in $(find dist/ -name '*.tgz'); do | ||
gh release upload $tag $f | ||
done |
This file contains 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,120 @@ | ||
|
||
--- | ||
version: 2 | ||
|
||
project_name: gitjob | ||
release: | ||
prerelease: auto | ||
|
||
before: | ||
hooks: | ||
- go mod download | ||
|
||
archives: | ||
- id: gitjob | ||
format: binary | ||
name_template: "{{ .Binary }}" | ||
builds: | ||
- gitjob | ||
|
||
builds: | ||
- | ||
id: gitjob | ||
main: ./ | ||
binary: gitjob-{{ .Os }}-{{ .Arch }}{{ if .Arm }}64{{ end }} | ||
no_unique_dist_dir: true | ||
# gcflags: | ||
# - all="-N -l" | ||
ldflags: | ||
- -w -s | ||
- -X github.com/rancher/gitjob/pkg/version.GitCommit={{ .Commit }} | ||
- -X github.com/rancher/gitjob/pkg/version.Version={{ .Tag }} | ||
targets: | ||
- linux_amd64_v1 | ||
- linux_arm64 | ||
- | ||
id: gitcloner | ||
main: ./cmd/gitcloner | ||
binary: gitcloner-{{ .Os }}-{{ .Arch }}{{ if .Arm }}64{{ end }} | ||
no_unique_dist_dir: true | ||
# gcflags: | ||
# - all="-N -l" | ||
ldflags: | ||
- -w -s | ||
- -X github.com/rancher/gitjob/pkg/version.GitCommit={{ .Commit }} | ||
- -X github.com/rancher/gitjob/pkg/version.Version={{ .Tag }} | ||
targets: | ||
- linux_amd64_v1 | ||
- linux_arm64 | ||
|
||
changelog: | ||
## Delegate Changelog to release-drafter | ||
disable: false | ||
use: github | ||
|
||
env: | ||
- CGO_ENABLED=0 | ||
|
||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
|
||
dockers: | ||
- | ||
use: buildx | ||
|
||
# GOOS of the built binaries/packages that should be used. | ||
goos: linux | ||
|
||
# GOARCH of the built binaries/packages that should be used. | ||
goarch: amd64 | ||
|
||
# IDs to filter the binaries/packages. | ||
ids: | ||
- gitjob | ||
- gitcloner | ||
|
||
# Templates of the Docker image names. | ||
image_templates: | ||
- "docker.io/rancher/gitjob:{{ .Tag }}-linux-amd64" | ||
|
||
# Path to the Dockerfile (from the project root). | ||
dockerfile: package/Dockerfile | ||
|
||
# Template of the docker build flags. | ||
build_flag_templates: | ||
- "--pull" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.title={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- "--label=org.opencontainers.image.source=https://github.com/rancher/gitjob" | ||
- "--build-arg=ARCH=amd64" | ||
- "--build-arg=BUILD_ENV=goreleaser" | ||
- "--platform=linux/amd64" | ||
- | ||
use: buildx | ||
goos: linux | ||
goarch: arm64 | ||
ids: | ||
- gitjob | ||
- gitcloner | ||
image_templates: | ||
- "docker.io/rancher/gitjob:{{ .Tag }}-linux-arm64" | ||
dockerfile: package/Dockerfile | ||
build_flag_templates: | ||
- "--pull" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.title={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- "--label=org.opencontainers.image.source=https://github.com/rancher/gitjob" | ||
- "--build-arg=ARCH=arm64" | ||
- "--build-arg=BUILD_ENV=goreleaser" | ||
- "--platform=linux/arm64/v8" | ||
|
||
docker_manifests: | ||
# https://goreleaser.com/customization/docker_manifest/ | ||
- name_template: "docker.io/rancher/gitjob:{{ .Tag }}" | ||
image_templates: | ||
- "docker.io/rancher/gitjob:{{ .Tag }}-linux-amd64" | ||
- "docker.io/rancher/gitjob:{{ .Tag }}-linux-arm64" |