Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 94 additions & 20 deletions .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,107 @@ defaults:
run:
shell: bash
jobs:
goreleaser:
release:
needs:
- build-windows
- build-darwin
- build-linux

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2

- run: |
for dist in dist-*; do
tar -C "${dist}" -xf "${dist}/${dist}.tar"
done

- name: Create assets
run: |
set -xe
mkdir -p assets
cat dist-*/dist/checksums.txt > assets/checksums.txt
for asset in dist-*/dist/*_*/*; do
base=$(basename "${asset}")
variant=$(basename $(dirname "${asset}") | cut -d_ -f1)
cp "${asset}" "assets/${variant}-${base}"
done
find assets -ls
cat assets/checksums.txt

- name: Upload Release Assets
if: github.ref_type == 'tag'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create "${{ github.ref_name }}" --generate-notes ./assets/*

build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
# GoReleaser requires fetch-depth: 0 to correctly
# run git describe
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: '~1.16'

- name: "Run GoReleaser"
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ARGS: release --rm-dist -f release/goreleaser.windows.yaml --skip-validate ${{ github.event_name == 'pull_request' && '--snapshot' || '' }}

- run: tar -cvf dist-windows.tar dist
- uses: actions/upload-artifact@v2
with:
name: dist-windows
path: dist-windows.tar

build-darwin:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
# GoReleaser requires fetch-depth: 0 for
# changelog generation to work correctly.
# GoReleaser requires fetch-depth: 0 to correctly
# run git describe
fetch-depth: 0

- uses: actions/setup-go@v2
with:
go-version: '~1.16'

- name: "Install linux cross-compilers"
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-s390x-linux-gnu gcc-powerpc64le-linux-gnu gcc-mingw-w64-x86-64
- name: "Run GoReleaser"
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ARGS: release --rm-dist -f release/goreleaser.darwin.yaml --skip-validate ${{ github.event_name == 'pull_request' && '--snapshot' || '' }}

- name: "Install yq"
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/v4.10.0/yq_linux_amd64 -O /usr/local/bin/yq
sudo chmod +x /usr/local/bin/yq
- run: tar -cvf dist-darwin.tar dist
- uses: actions/upload-artifact@v2
with:
name: dist-darwin
path: dist-darwin.tar

- name: "Disable image pushes for pull requests"
if: github.event_name == 'pull_request'
run: |
yq eval '.dockers[].skip_push=true' -i .goreleaser.yaml
yq eval '.docker_manifests[].skip_push=true' -i .goreleaser.yaml
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# GoReleaser requires fetch-depth: 0 to correctly
# run git describe
fetch-depth: 0

- uses: actions/setup-go@v2
with:
go-version: '~1.16'

- name: "Disable the Github release upload for non-tag builds"
if: startsWith(github.ref, 'refs/tags') != true
- name: "Install linux cross-compilers"
run: |
yq eval '.release.disable=true' -i .goreleaser.yaml
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-s390x-linux-gnu gcc-powerpc64le-linux-gnu

- name: "Set the image tag"
run: |
Expand Down Expand Up @@ -74,4 +142,10 @@ jobs:
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ARGS: release --rm-dist ${{ !startsWith(github.ref, 'refs/tags') && '--skip-validate' || '' }}
RELEASE_ARGS: release --rm-dist -f release/goreleaser.linux.yaml --skip-validate ${{ github.event_name == 'pull_request' && '--snapshot' || '' }}

- run: tar -cvf dist-linux.tar dist
- uses: actions/upload-artifact@v2
with:
name: dist-linux
path: dist-linux.tar
48 changes: 0 additions & 48 deletions .github/workflows/release.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ export LATEST_IMAGE_OR_EMPTY ?= $(shell \
echo $(OPM_VERSION) | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$$' \
&& [ "$(shell echo -e "$(OPM_VERSION)\n$(LATEST_TAG)" | sort -rV | head -n1)" == "$(OPM_VERSION)" ] \
&& echo "$(OPM_IMAGE_REPO):latest" || echo "")
release: RELEASE_ARGS ?= release --rm-dist --snapshot
release: RELEASE_ARGS ?= release --rm-dist --snapshot -f release/goreleaser.$(shell go env GOOS).yaml
release:
./scripts/fetch goreleaser 0.177.0 && ./bin/goreleaser $(RELEASE_ARGS)
./scripts/fetch goreleaser 1.4.1 && ./bin/goreleaser $(RELEASE_ARGS)

# tagged-or-empty returns $(OPM_IMAGE_REPO):$(1) when HEAD is assigned a non-prerelease semver tag,
# otherwise the empty string. An empty string causes goreleaser to skip building
Expand Down
49 changes: 49 additions & 0 deletions release/goreleaser.darwin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
builds:
- id: darwin-amd64
main: ./cmd/opm
binary: opm
goos:
- darwin
goarch:
- amd64
env:
- CGO_ENABLED=1
mod_timestamp: "{{ .CommitTimestamp }}"
flags: &build-flags
- -tags=json1
asmflags: &build-asmflags
- all=-trimpath={{ .Env.PWD }}
gcflags: &build-gcflags
- all=-trimpath={{ .Env.PWD }}
ldflags: &build-ldflags
- -s -w
- -X {{ .Env.PKG }}/cmd/opm/version.gitCommit={{ .Env.GIT_COMMIT }}
- -X {{ .Env.PKG }}/cmd/opm/version.opmVersion={{ .Env.OPM_VERSION }}
- -X {{ .Env.PKG }}/cmd/opm/version.buildDate={{ .Env.BUILD_DATE }}
- id: darwin-arm64
main: ./cmd/opm
binary: opm
goos:
- darwin
goarch:
- arm64
env:
- CGO_ENABLED=1
mod_timestamp: "{{ .CommitTimestamp }}"
flags: *build-flags
asmflags: *build-asmflags
gcflags: *build-gcflags
ldflags: *build-ldflags
archives:
- id: opm
builds:
- darwin-amd64
- darwin-arm64
format: binary
name_template: "{{ .Os }}-{{ .Arch }}-{{ .Binary }}"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Env.OPM_VERSION }}"
release:
disable: true
22 changes: 1 addition & 21 deletions .goreleaser.yaml → release/goreleaser.linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,15 @@ builds:
asmflags: *build-asmflags
gcflags: *build-gcflags
ldflags: *build-ldflags
- id: windows-amd64
main: ./cmd/opm
binary: opm
goos:
- windows
goarch:
- amd64
env:
- CC=x86_64-w64-mingw32-gcc-posix
- CGO_ENABLED=1
mod_timestamp: "{{ .CommitTimestamp }}"
flags: *build-flags
asmflags: *build-asmflags
gcflags: *build-gcflags
ldflags: *build-ldflags
archives:
- id: opm
builds:
- linux-amd64
- linux-arm64
- linux-ppc64le
- linux-s390x
- windows-amd64
name_template: "{{ .Binary }}_{{ .Env.OPM_VERSION }}_{{ .Os }}_{{ .Arch }}"
format: binary
name_template: "{{ .Os }}-{{ .Arch }}-{{ .Binary }}"
dockers:
- image_templates:
- "{{ .Env.OPM_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64"
Expand Down Expand Up @@ -167,8 +151,4 @@ checksum:
snapshot:
name_template: "{{ .Env.OPM_VERSION }}"
release:
name_template: "{{ .Env.OPM_VERSION }}"
draft: true
## Disable release steps, since a separate GitHub Action job
## handles binary builds and release uploads
disable: true
10 changes: 2 additions & 8 deletions release/goreleaser.opm.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
# build opm images. See the configurations in .goreleaser.yaml
# and .github/workflows/release.yaml.

FROM alpine as grpc_health_probe
ARG TARGETARCH
RUN apk update && \
apk add curl && \
curl --silent --show-error --location --output /grpc_health_probe \
https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.4.5/grpc_health_probe-linux-$TARGETARCH && \
chmod 755 /grpc_health_probe
FROM ghcr.io/grpc-ecosystem/grpc-health-probe:v0.4.6 as grpc_health_probe
FROM gcr.io/distroless/static:debug
COPY --from=grpc_health_probe /grpc_health_probe /bin/grpc_health_probe
COPY --from=grpc_health_probe /ko-app/grpc-health-probe /bin/grpc_health_probe
COPY ["nsswitch.conf", "/etc/nsswitch.conf"]
COPY opm /bin/opm
ENTRYPOINT ["/bin/opm"]
35 changes: 35 additions & 0 deletions release/goreleaser.windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
builds:
- id: windows-amd64
main: ./cmd/opm
binary: opm
goos:
- windows
goarch:
- amd64
env:
- CGO_ENABLED=1
mod_timestamp: "{{ .CommitTimestamp }}"
flags: &build-flags
- -tags=json1,netgo,osusergo
asmflags: &build-asmflags
- all=-trimpath={{ .Env.PWD }}
gcflags: &build-gcflags
- all=-trimpath={{ .Env.PWD }}
ldflags: &build-ldflags
- -s -w
- -extldflags=-static
- -X {{ .Env.PKG }}/cmd/opm/version.gitCommit={{ .Env.GIT_COMMIT }}
- -X {{ .Env.PKG }}/cmd/opm/version.opmVersion={{ .Env.OPM_VERSION }}
- -X {{ .Env.PKG }}/cmd/opm/version.buildDate={{ .Env.BUILD_DATE }}
archives:
- id: opm
builds:
- windows-amd64
format: binary
name_template: "{{ .Os }}-{{ .Arch }}-{{ .Binary }}"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Env.OPM_VERSION }}"
release:
disable: true
2 changes: 1 addition & 1 deletion scripts/fetch
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fetch() {
;;
"goreleaser")
ver_cmd="${ROOT}/bin/goreleaser --version 2>/dev/null | grep 'goreleaser version' | cut -d' ' -f3"
fetch_cmd="curl -sSfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh -s -- -b \"${ROOT}/bin\" -d \"v${ver}\""
fetch_cmd="GOBIN=${ROOT}/bin go install github.com/goreleaser/goreleaser@v${ver}"
;;
*)
echo "unknown tool $tool"
Expand Down