fix: go build ldflags (#449) #148
Workflow file for this run
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
name: Release | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
jobs: | |
version: | |
name: Set Version from git ref | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- id: version | |
run: echo "::set-output name=version::$(sed 's#^refs/tags/\(.*\)#\1#' <<< '${{ github.ref }}')" | |
binaries: | |
name: Binaries | |
runs-on: ubuntu-latest | |
needs: version | |
env: | |
VERSION: ${{ needs.version.outputs.version }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
HOMEBREW_RELEASE_PAT: ${{ secrets.HOMEBREW_RELEASE_PAT }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- name: Generate Release Notes | |
run: scripts/release-notes.sh $VERSION > /tmp/release-notes.md | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v6 | |
with: | |
args: release --clean --parallelism 5 --release-notes /tmp/release-notes.md --verbose | |
images: | |
name: Docker Images | |
runs-on: ubuntu-latest | |
needs: version | |
env: | |
VERSION: ${{ needs.version.outputs.version }} | |
BUILD_DATE_VAR: 'github.com/flomesh-io/fsm/pkg/version.BuildDate' | |
BUILD_VERSION_VAR: 'github.com/flomesh-io/fsm/pkg/version.Version' | |
BUILD_GITCOMMIT_VAR: 'github.com/flomesh-io/fsm/pkg/version.GitCommit' | |
strategy: | |
matrix: | |
id: [ "curl", "sidecar-init", "controller", "injector", "connector", "crds", "bootstrap", "preinstall", "healthcheck", "interceptor", "ingress", "gateway" ] | |
steps: | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Login to DockerHub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.RELEASE_DOCKER_USER }} | |
password: ${{ secrets.RELEASE_DOCKER_PASS }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- name: Package Helm Charts | |
run: make charts-tgz | |
- name: Docker meta - ${{ matrix.id }} | |
id: docker_meta | |
uses: crazy-max/[email protected] | |
with: | |
images: ${{ secrets.RELEASE_REGISTRY }}/fsm-${{ matrix.id }} | |
tags: | | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}}.{{minor}}.{{patch}} | |
type=sha,format=short | |
flavor: | | |
latest=auto | |
- name: Get Build Info | |
run: | | |
echo "BUILD_DATE=$(date +%Y-%m-%d-%H:%M)" >> $GITHUB_ENV | |
echo "GIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
- name: Build and Push - ${{ matrix.id }} | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: ./dockerfiles/Dockerfile.fsm-${{ matrix.id }} | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
GO_VERSION=1.23 | |
LDFLAGS=-X ${{ env.BUILD_DATE_VAR }}=${{ env.BUILD_DATE }} -X ${{ env.BUILD_VERSION_VAR }}=${{ env.VERSION }} -X ${{ env.BUILD_GITCOMMIT_VAR }}=${{ env.GIT_SHA }} -s -w | |
DISTROLESS_TAG=nonroot | |
push: ${{ (github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) )) }} | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
demo-images: | |
name: Demo Docker Images | |
runs-on: ubuntu-latest | |
needs: version | |
strategy: | |
matrix: | |
id: [ "bookbuyer", "bookthief", "bookstore", "bookwarehouse", "tcp-echo-server", "tcp-client" ] | |
steps: | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Login to DockerHub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.RELEASE_DOCKER_USER }} | |
password: ${{ secrets.RELEASE_DOCKER_PASS }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- name: Docker meta - ${{ matrix.id }} | |
id: docker_meta | |
uses: crazy-max/[email protected] | |
with: | |
images: ${{ secrets.RELEASE_REGISTRY }}/fsm-demo-${{ matrix.id }} | |
tags: | | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}}.{{minor}}.{{patch}} | |
type=sha,format=short | |
flavor: | | |
latest=auto | |
- name: Build and Push - ${{ matrix.id }} | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: ./dockerfiles/Dockerfile.demo | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
GO_VERSION=1.23 | |
BINARY=${{ matrix.id }} | |
push: ${{ (github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) )) }} | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_meta.outputs.labels }} |