-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: timflannagan <timflannagan@gmail.com>
- Loading branch information
1 parent
1b8cf1d
commit 7b07d89
Showing
4 changed files
with
140 additions
and
14 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,66 @@ | ||
name: Release | ||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
packages: write | ||
|
||
jobs: | ||
goreleaser: | ||
name: goreleaser | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: "go.mod" | ||
cache: true | ||
|
||
- name: Log into ghcr.io | ||
if: ${{ github.event_name != 'pull_request' }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.IMAGE_REGISTRY }} | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set the release related variables | ||
id: set_vars | ||
run: | | ||
# we want to conditionally run the full release pipeline based on the | ||
# event that triggered the workflow. for PRs, we only want to build | ||
# the binaries & container images, but not create a release. | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
VERSION="${GITHUB_REF#refs/tags/}" | ||
echo "GORELEASER_ARGS=--clean" >> $GITHUB_ENV | ||
elif [[ $GITHUB_REF == refs/heads/main ]]; then | ||
VERSION="$(echo "${GITHUB_REF#refs/heads/}" | sed -r 's|/+|-|g')" | ||
echo "GORELEASER_ARGS=--clean --skip=validate" >> $GITHUB_ENV | ||
elif [[ $GITHUB_REF == refs/pull/* ]]; then | ||
VERSION="pr-$(echo "${GITHUB_REF}" | sed -E 's|refs/pull/([^/]+)/?.*|\1|')" | ||
else | ||
VERSION="$(git describe --tags --always)" | ||
fi | ||
echo "VERSION=${VERSION}" >> $GITHUB_ENV | ||
- name: Run goreleaser | ||
run: make release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
VERSION: ${{ env.VERSION }} | ||
IMAGE_REGISTRY: ${{ env.IMAGE_REGISTRY }} | ||
GORELEASER_ARGS: ${{ env.GORELEASER_ARGS }} |
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 |
---|---|---|
|
@@ -57,3 +57,5 @@ istio-*/* | |
|
||
# Bin directory created by e2e test | ||
.bin/ | ||
# Added by goreleaser init: | ||
dist/ |
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,55 @@ | ||
version: 2 | ||
before: | ||
hooks: | ||
- go mod tidy | ||
- go mod download | ||
builds: | ||
- id: controller | ||
main: ./projects/gloo/cmd/ | ||
binary: gloo-linux-{{ .Arch }} | ||
gcflags: "{{ .Env.GCFLAGS }}" | ||
ldflags: "{{ .Env.LDFLAGS }}" | ||
env: | ||
- CGO_ENABLED=0 | ||
- GO111MODULE=on | ||
- GOARCH={{ .Arch }} | ||
- GOOS={{ .Os }} | ||
mod_timestamp: "{{ .CommitTimestamp }}" | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
dockers: | ||
- image_templates: | ||
- &arm_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.IMAGE_REPO }}:{{ .Env.VERSION }}-arm64" | ||
use: buildx | ||
dockerfile: &dockerfile projects/gloo/cmd/Dockerfile | ||
goos: linux | ||
goarch: arm64 | ||
build_flag_templates: | ||
- "--pull" | ||
- "--platform=linux/arm64" | ||
- "--build-arg=GOARCH=arm64" | ||
- "--build-arg=ENVOY_IMAGE={{ .Env.ENVOY_GLOO_IMAGE }}" | ||
- image_templates: | ||
- &amd_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.IMAGE_REPO }}:{{ .Env.VERSION }}-amd64" | ||
use: buildx | ||
dockerfile: *dockerfile | ||
goos: linux | ||
goarch: amd64 | ||
build_flag_templates: | ||
- "--pull" | ||
- "--platform=linux/amd64" | ||
- "--build-arg=GOARCH=amd64" | ||
- "--build-arg=ENVOY_IMAGE={{ .Env.ENVOY_GLOO_IMAGE }}" | ||
docker_manifests: | ||
- name_template: "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.IMAGE_REPO }}:{{ .Env.VERSION }}" | ||
image_templates: | ||
- *amd_image | ||
- *arm_image | ||
changelog: | ||
disable: false | ||
release: | ||
prerelease: "auto" | ||
mode: "replace" |
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