From 06b50ae9b6f6e9b1f381fafe9d5c4d079c716bf8 Mon Sep 17 00:00:00 2001 From: likfees Date: Mon, 1 Jan 2024 15:58:27 +0800 Subject: [PATCH] update workflows --- .github/workflows/release.yml | 63 ++++++++++++++------ .goreleaser.yaml | 105 +++++++++++++++++----------------- 2 files changed, 99 insertions(+), 69 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4659316..0e3003c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,21 +17,52 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - run: git fetch --force --tags - - uses: actions/setup-go@v3 + - uses: arduino/setup-task@v1 with: - go-version: '>=1.20.2' - cache: true - # More assembly might be required: Docker logins, GPG, etc. It all depends - # on your needs. - - uses: goreleaser/goreleaser-action@v4 + version: 3.x + repo-token: ${{ secrets.GH_TOKEN }} + - uses: docker/setup-qemu-action@v2 # v2 + - uses: docker/setup-buildx-action@v2 # v2 + - name: setup-snapcraft + run: | + sudo apt-get update + sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft + mkdir -p $HOME/.cache/snapcraft/download + mkdir -p $HOME/.cache/snapcraft/stage-packages + - uses: actions/setup-go@v1 with: - # either 'goreleaser' (default) or 'goreleaser-pro': - distribution: goreleaser - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' - # distribution: - # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + go-version: stable + - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3 + with: + path: | + ./dist/*.deb + ./dist/*.rpm + ./dist/*.apk + key: ${{ github.ref }} + - uses: sigstore/cosign-installer@v3.3.0 + - uses: anchore/sbom-action/download-syft@v0.15.1 + - uses: crazy-max/ghaction-upx@v3 + with: + install-only: true + - name: dockerhub-login + if: startsWith(github.ref, 'refs/tags/v') + uses: docker/login-action@v2# v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: goreleaser-release + run: task goreleaser + + +# - run: git fetch --force --tags +# - uses: actions/setup-go@v3 +# with: +# go-version: '>=1.20.2' +# cache: true +# - uses: goreleaser/goreleaser-action@v4 +# with: +# distribution: goreleaser +# version: latest +# args: release --clean +# env: +# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 8cf3600..6aa3547 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -95,56 +95,55 @@ snapshot: # yaml-language-server: $schema=https://goreleaser.com/static/schema.json # vim: set ts=2 sw=2 tw=0 fo=cnqoj -# -#docker_signs: -# - cmd: cosign -# artifacts: manifests -# output: true -# args: -# - "sign" -# - "${artifact}@${digest}" -# - --yes -# -# -#dockers: -# - image_templates: -# - "goreleaser/goreleaser:v{{ .Version }}-amd64" -# - "ghcr.io/goreleaser/goreleaser:v{{ .Version }}-amd64" -# dockerfile: Dockerfile -# use: buildx -# build_flag_templates: -# - "--pull" -# - "--label=io.artifacthub.package.readme-url=https://raw.githubusercontent.com/goreleaser/goreleaser/main/README.md" -# - "--label=io.artifacthub.package.logo-url=https://goreleaser.com/static/avatar.png" -# - '--label=io.artifacthub.package.maintainers=[{"name":"Carlos Alexandro Becker","email":"carlos@carlosbecker.dev"}]' -# - "--label=io.artifacthub.package.license=MIT" -# - "--label=org.opencontainers.image.description=Deliver Go binaries as fast and easily as possible" -# - "--label=org.opencontainers.image.created={{.Date}}" -# - "--label=org.opencontainers.image.name={{.ProjectName}}" -# - "--label=org.opencontainers.image.revision={{.FullCommit}}" -# - "--label=org.opencontainers.image.version={{.Version}}" -# - "--label=org.opencontainers.image.source={{.GitURL}}" -# - "--platform=linux/amd64" -# extra_files: -# - scripts/entrypoint.sh -# - image_templates: -# - "goreleaser/goreleaser:v{{ .Version }}-arm64" -# - "ghcr.io/goreleaser/goreleaser:v{{ .Version }}-arm64" -# dockerfile: Dockerfile -# use: buildx -# build_flag_templates: -# - "--pull" -# - "--label=io.artifacthub.package.readme-url=https://raw.githubusercontent.com/goreleaser/goreleaser/main/README.md" -# - "--label=io.artifacthub.package.logo-url=https://goreleaser.com/static/avatar.png" -# - '--label=io.artifacthub.package.maintainers=[{"name":"Carlos Alexandro Becker","email":"carlos@carlosbecker.dev"}]' -# - "--label=io.artifacthub.package.license=MIT" -# - "--label=org.opencontainers.image.description=Deliver Go binaries as fast and easily as possible" -# - "--label=org.opencontainers.image.created={{.Date}}" -# - "--label=org.opencontainers.image.name={{.ProjectName}}" -# - "--label=org.opencontainers.image.revision={{.FullCommit}}" -# - "--label=org.opencontainers.image.version={{.Version}}" -# - "--label=org.opencontainers.image.source={{.GitURL}}" -# - "--platform=linux/arm64" -# goarch: arm64 -# extra_files: -# - scripts/entrypoint.sh +docker_signs: + - cmd: cosign + artifacts: manifests + output: true + args: + - "sign" + - "${artifact}@${digest}" + - --yes + + +dockers: + - image_templates: + - "goreleaser/goreleaser:v{{ .Version }}-amd64" + - "ghcr.io/goreleaser/goreleaser:v{{ .Version }}-amd64" + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - "--pull" + - "--label=io.artifacthub.package.readme-url=https://raw.githubusercontent.com/goreleaser/goreleaser/main/README.md" + - "--label=io.artifacthub.package.logo-url=https://goreleaser.com/static/avatar.png" + - '--label=io.artifacthub.package.maintainers=[{"name":"Carlos Alexandro Becker","email":"carlos@carlosbecker.dev"}]' + - "--label=io.artifacthub.package.license=MIT" + - "--label=org.opencontainers.image.description=Deliver Go binaries as fast and easily as possible" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.name={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.source={{.GitURL}}" + - "--platform=linux/amd64" + extra_files: + - scripts/entrypoint.sh + - image_templates: + - "goreleaser/goreleaser:v{{ .Version }}-arm64" + - "ghcr.io/goreleaser/goreleaser:v{{ .Version }}-arm64" + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - "--pull" + - "--label=io.artifacthub.package.readme-url=https://raw.githubusercontent.com/goreleaser/goreleaser/main/README.md" + - "--label=io.artifacthub.package.logo-url=https://goreleaser.com/static/avatar.png" + - '--label=io.artifacthub.package.maintainers=[{"name":"Carlos Alexandro Becker","email":"carlos@carlosbecker.dev"}]' + - "--label=io.artifacthub.package.license=MIT" + - "--label=org.opencontainers.image.description=Deliver Go binaries as fast and easily as possible" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.name={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.source={{.GitURL}}" + - "--platform=linux/arm64" + goarch: arm64 + extra_files: + - scripts/entrypoint.sh