Skip to content

Commit

Permalink
build: setup release pipeline after transfer (#100)
Browse files Browse the repository at this point in the history
Continuation of #95

Release-As: 1.2.0-rc0
  • Loading branch information
jooola authored Nov 2, 2023
1 parent b382ed6 commit 08c9695
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 46 deletions.
26 changes: 10 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,41 @@
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release

on:
push:
tags:
- 'v*'
- "v*"

permissions:
contents: write
packages: read

jobs:
get-go-version:
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.get-go-version.outputs.go-version }}
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: 'Determine Go version'
id: get-go-version
run: |
echo "Found Go $(cat .go-version)"
echo "go-version=$(cat .go-version)" >> $GITHUB_OUTPUT
goreleaser:
needs:
- get-go-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Unshallow
run: git fetch --prune --unshallow

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
go-version: "1.20"

- name: Describe plugin
id: plugin_describe
run: echo "api_version=$(go run . describe | jq -r '.api_version')" >> "$GITHUB_OUTPUT"

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@111c56156bcc6918c056dbef52164cfa583dc549 # v5.2.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
with:
Expand Down
62 changes: 32 additions & 30 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,66 @@
# Make sure to check the documentation at http://goreleaser.com
env:
- CGO_ENABLED=0

before:
hooks:
# We strongly recommend running tests to catch any regression before release.
# Even though, this an optional step.
- go test ./...
# Check plugin compatibility with required version of the Packer SDK
- make plugin-check

builds:
# A separated build to run the packer-plugins-check only once for a linux_amd64 binary
-
id: plugin-check
mod_timestamp: '{{ .CommitTimestamp }}'
- id: plugin-check
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -trimpath #removes all file system paths from the compiled executable
ldflags:
- '-s -w -X {{ .ModulePath }}/version.Version={{.Version}} -X {{ .ModulePath }}/version.VersionPrerelease= '
- "-s -w -X {{ .ModulePath }}/version.Version={{.Version}} -X {{ .ModulePath }}/version.VersionPrerelease= "
goos:
- linux
goarch:
- amd64
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
-
id: linux-builds
mod_timestamp: '{{ .CommitTimestamp }}'
binary: "{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}"

- id: linux-builds
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -trimpath #removes all file system paths from the compiled executable
ldflags:
- '-s -w -X {{ .ModulePath }}/version.Version={{.Version}} -X {{ .ModulePath }}/version.VersionPrerelease= '
- "-s -w -X {{ .ModulePath }}/version.Version={{.Version}} -X {{ .ModulePath }}/version.VersionPrerelease= "
goos:
- linux
goarch:
- amd64
- '386'
- "386"
- arm
- arm64
ignore:
- goos: linux
goarch: amd64
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
-
id: darwin-builds
mod_timestamp: '{{ .CommitTimestamp }}'
binary: "{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}"

- id: darwin-builds
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -trimpath #removes all file system paths from the compiled executable
ldflags:
- '-s -w -X {{ .ModulePath }}/version.Version={{.Version}} -X {{ .ModulePath }}/version.VersionPrerelease= '
- "-s -w -X {{ .ModulePath }}/version.Version={{.Version}} -X {{ .ModulePath }}/version.VersionPrerelease= "
goos:
- darwin
goarch:
- amd64
- arm64
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
-
id: other-builds
mod_timestamp: '{{ .CommitTimestamp }}'
binary: "{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}"

- id: other-builds
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -trimpath #removes all file system paths from the compiled executable
ldflags:
- '-s -w -X {{ .ModulePath }}/version.Version={{.Version}} -X {{ .ModulePath }}/version.VersionPrerelease= '
- "-s -w -X {{ .ModulePath }}/version.Version={{.Version}} -X {{ .ModulePath }}/version.VersionPrerelease= "
goos:
- netbsd
- openbsd
Expand All @@ -72,24 +73,27 @@ builds:
- solaris
goarch:
- amd64
- '386'
- "386"
- arm
ignore:
- goos: windows
goarch: arm
- goos: solaris
goarch: arm
- goos: solaris
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
goarch: "386"
binary: "{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}"

archives:
- format: zip
files:
- none*
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
- format: zip
files:
- none*
name_template: "{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}"

checksum:
name_template: '{{ .ProjectName }}_v{{ .Version }}_SHA256SUMS'
name_template: "{{ .ProjectName }}_v{{ .Version }}_SHA256SUMS"
algorithm: sha256

signs:
- artifacts: checksum
args:
Expand All @@ -102,5 +106,3 @@ signs:
- "${signature}"
- "--detach-sign"
- "${artifact}"
changelog:
use: github-native

0 comments on commit 08c9695

Please sign in to comment.