Skip to content

Commit

Permalink
split platform builds
Browse files Browse the repository at this point in the history
Splits the release builds to corresponding platforms.
Introduces go-releaser configuration for each platform.
adds a new workflow that uses gh CLI to do the publish.
  • Loading branch information
gorkem committed Apr 14, 2024
1 parent 98862e9 commit 87616a5
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 168 deletions.
163 changes: 163 additions & 0 deletions .github/workflows/platform-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: Release with Platform builds

on:
workflow_dispatch:
inputs:
skip_signing:
description: 'Skip code signing'
required: true
default: false
type: boolean
push:
tags:
- 'v*'

permissions:
contents: write
jobs:
build-macos:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

# - name: Import Apple Code Signing Certificates
# if: ${{ github.event_name != 'workflow_dispatch' || !inputs.skip_signing }}
# uses: Apple-Actions/import-codesign-certs@v2
# with:
# p12-file-base64: ${{ secrets.APPLE_CERTIFICATE_BASE64 }}
# p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
distribution: goreleaser
args: release --clean --snapshot --config ./.goreleaser.darwin.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APPLE_DEVELOPER_ID: ${{ secrets.APPLICATION_IDENTITY}}
APPLE_ID: ${{ vars.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD}}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID}}
- name: Notarize the macOS binary
run: |
./build/scripts/sign ./dist/kitops-darwin-amd64.zip
./build/scripts/sign ./dist/kitops-darwin-x86_64.zip
- name: Upload macOS artifacts
uses: actions/upload-artifact@v4
with:
name: dist-macos
if-no-files-found: error
retention-days: 7
path: |
./dist/*.zip
build-windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
distribution: goreleaser
args: release --clean --snapshot --config ./.goreleaser.windows.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: dist-windows
if-no-files-found: error
retention-days: 7
path: |
./dist/*.zip
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
distribution: goreleaser
args: release --clean --snapshot --config ./.goreleaser.linux.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Linux artifacts
uses: actions/upload-artifact@v4
with:
name: dist-linux
if-no-files-found: error
retention-days: 7
path: |
./dist/*.tar.gz
release:
runs-on: ubuntu-latest
needs: [build-linux, build-macos, build-windows]
steps:
- name: Merge built artifacts
uses: actions/download-artifact@v4
with:
path: dist
pattern: dist-*
merge-multiple: true
- name: Create Checksums
env:
TAG_NAME: ${{ github.ref_name}}
run: |
shopt -s failglob
pushd dist
shasum -a 256 kitops-* > checksums.txt
mv checksums.txt kitops_${TAG_NAME}_checksums.txt
popd
- name: Create Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name}}
REPO: ${{ github.repository }}
run: |
echo "Creating release for ${TAG_NAME}"
previous_release="$(gh release list --repo $REPO --limit 1 --json tagName --jq '.[] | .tagName ')"
gh release create \
${TAG_NAME} \
./dist/*.* \
--title "Release ${TAG_NAME}" \
--generate-notes \
--repo ${REPO} \
--notes-start-tag "${previous_release}" \
--verify-tag \
--latest
- name: Generate CLI documentation
run: |
docs/src/docs/cli/generate.sh > /dev/null
- name: PR for CLI documentation
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
docs/*.md
commit-message: "docs: update CLI documentation for ${{ github.ref_name }}"
52 changes: 0 additions & 52 deletions .github/workflows/release.yaml

This file was deleted.

47 changes: 47 additions & 0 deletions .goreleaser.darwin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

version: 1

project_name: kitops

before:
hooks:
- go mod tidy

builds:
- id: "kit-macos"
env:
- CGO_ENABLED=0
goos:
- darwin
goarch:
- amd64
- arm64
binary: kit
ldflags:
- -s -w -X kitops/pkg/cmd/version.Version={{.Version}} -X kitops/pkg/cmd/version.GitCommit={{.Commit}} -X kitops/pkg/cmd/version.BuildTime={{.CommitDate}}
hooks:
post:
- cmd: ./build/scripts/sign '{{ .Path }}'
output: true

archives:
- id: kit-macos-archive
format: zip
builds:
- kit-macos
name_template: >-
{{ .ProjectName }}-
{{- tolower .Os }}-
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
wrap_in_directory: true
rlcp: true
files:
- LICENSE
- README.md

git:
ignore_tags:
- "next"
39 changes: 39 additions & 0 deletions .goreleaser.linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

version: 1

project_name: kitops

before:
hooks:
- go mod tidy

builds:
- id: "kit-linux"
env:
- CGO_ENABLED=0
goos:
- linux
binary: kit
ldflags:
- -s -w -X kitops/pkg/cmd/version.Version={{.Version}} -X kitops/pkg/cmd/version.GitCommit={{.Commit}} -X kitops/pkg/cmd/version.BuildTime={{.CommitDate}}

archives:
- id: kit-archive
format: tar.gz
builds:
- kit-linux
name_template: >-
{{ .ProjectName }}-
{{- tolower .Os }}-
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
rlcp: true
files:
- LICENSE
- README.md

git:
ignore_tags:
- "next"
37 changes: 37 additions & 0 deletions .goreleaser.windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

version: 1

project_name: kitops

before:
hooks:
- go mod tidy

builds:
- id: "kit-wins"
env:
- CGO_ENABLED=0
goos:
- windows
binary: kit
ldflags:
- -s -w -X kitops/pkg/cmd/version.Version={{.Version}} -X kitops/pkg/cmd/version.GitCommit={{.Commit}} -X kitops/pkg/cmd/version.BuildTime={{.CommitDate}}

archives:
- id: kit-archive
format: zip
builds:
- kit-wins
name_template: >-
{{ .ProjectName }}-
{{- tolower .Os }}-
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
rlcp: true
files:
- LICENSE
- README.md


Loading

0 comments on commit 87616a5

Please sign in to comment.