From 3c7baf47ce0531edaa3eee3688d90e60c8f13de9 Mon Sep 17 00:00:00 2001 From: James Telfer <792299+jamestelfer@users.noreply.github.com> Date: Mon, 6 May 2024 15:23:44 +1000 Subject: [PATCH 1/2] ci: satisfy schema linter Use the long form instead. --- .github/workflows/test.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 259d578..3193580 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,7 +2,8 @@ name: Test and coverage on: push: - branches: main + branches: + - main pull_request: From 7a7d49f68a2ffa3c39d8f1c084dfc06af629ff5a Mon Sep 17 00:00:00 2001 From: James Telfer <792299+jamestelfer@users.noreply.github.com> Date: Mon, 6 May 2024 16:04:36 +1000 Subject: [PATCH 2/2] ci: add GoReleaser release workload and automation --- .github/workflows/release.yaml | 43 +++++++++++++++++++ .goreleaser.yaml | 76 ++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..0d181f8 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,43 @@ +name: Release + +on: + push: + # version tags are protected in this repository + tags: + - "v*" + +permissions: + contents: write + +jobs: + goreleaser: + # deploy with the correct environment to allow DockerHub access + environment: Publish + + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Release + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: v1.25.1 + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..65963ad --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,76 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json + +builds: + - id: release + binary: chinmina-bridge + env: + - CGO_ENABLED=0 + goos: + - darwin + - linux + goarch: + - amd64 + - arm64 + +checksum: + name_template: "checksums.txt" + +archives: + - format: tar.gz + name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" + +changelog: + use: github-native + sort: asc + +release: + prerelease: auto + header: | + # chinmina-bridge ({{ .Version }}) + + Binaries of this build can be found below, if these are needed. + + The preferred way to consume a release is via its [Docker + image](https://hub.docker.com/r/chinmina/chinmina-bridge): + + ```text + chinmina/chinmina-bridge:{{ .Tag }} + ``` + + The image is published for Linux for both x86-64 and ARM-64. + +kos: + - + id: chinmina-bridge + build: release + working_dir: . + base_image: cgr.dev/chainguard/static + + repository: chinmina + + # Platforms to build and publish. + # + # Default: 'linux/amd64' + platforms: + - linux/amd64 + - linux/arm64 + + # Tag to build and push. + # Empty tags are ignored. + # + # Default: 'latest' + # Templates: allowed + tags: + - "{{if not .Prerelease}}latest{{end}}" + - "{{.Tag}}" + + sbom: spdx + + # Bare uses a tag on the $KO_DOCKER_REPO without anything additional. + bare: true + + # Whether to preserve the full import path after the repository name. + preserve_import_paths: false + + # Whether to use the base path without the MD5 hash after the repository name. + base_import_paths: true