Skip to content

Commit

Permalink
add plrlctl formula to homebrew-plural and revert to single job build…
Browse files Browse the repository at this point in the history
… and release (#558)

* add plrlctl formula to homebrew-plural

* disable goreleaser split build and use single CI job

* update gh action ci check

* use goreleaser build instead of release for ci

---------

Co-authored-by: Sebastian Florek <[email protected]>
  • Loading branch information
zreigz and floreks authored Oct 3, 2024
1 parent 9bad017 commit 3b792d2
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 137 deletions.
35 changes: 2 additions & 33 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,7 @@ jobs:
version: v1.59.1
build:
name: GoReleaser build
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: ubuntu-latest
goos: linux
- os: macos-latest
goos: darwin
- os: windows-latest
goos: windows
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -287,34 +277,13 @@ jobs:
uses: actions/[email protected]
with:
go-version-file: go.mod
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.18.1
- name: Setup SHA variable
shell: bash
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Setup Cache
uses: actions/[email protected]
with:
path: dist/${{ matrix.goos }}
key: ${{ matrix.goos }}-${{ env.sha_short }}
enableCrossOsArchive: true
- name: Install Dependencies
if: matrix.goos == 'linux'
shell: bash
run: |
sudo apt update
sudo apt install -y libwebkit2gtk-4.0-dev libgtk-3-dev
- name: GoReleaser (Build)
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser-pro
version: '~> v2'
args: release --clean --split --timeout 90m
args: build --clean --snapshot --timeout 90m
env:
CGO_LDFLAGS: "${{ matrix.goos == 'darwin' && '-framework UniformTypeIdentifiers' || '' }}"
GOOS: ${{ matrix.GOOS }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLAB_CLIENT_SECRET: ${{ secrets.GITLAB_CLIENT_SECRET }}
Expand Down
86 changes: 1 addition & 85 deletions .github/workflows/goreleaser-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,9 @@ on:
- 'v*.*.*'

jobs:
# Build binaries with GoReleaser
prepare:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: ubuntu-latest
goos: linux
- os: macos-latest
goos: darwin
- os: windows-latest
goos: windows
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/[email protected]
with:
go-version-file: go.mod
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.18.1
- name: Setup Cache
uses: actions/[email protected]
with:
path: dist/${{ matrix.goos }}
key: ${{ matrix.goos }}-${{ github.ref_name }}
enableCrossOsArchive: true
- name: Install Dependencies
if: matrix.goos == 'linux'
shell: bash
run: |
sudo apt update
sudo apt install -y libwebkit2gtk-4.0-dev libgtk-3-dev
- name: Build web
shell: bash
run: make build-web
- name: Get Previous Tag
id: prev
uses: WyriHaximus/github-action-get-previous-tag@v1
env:
INPUT_PREFIX: v
- name: GoReleaser (Build)
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser-pro
version: '~> v2'
args: release --clean --split --timeout 90m
env:
CGO_LDFLAGS: "${{ matrix.goos == 'darwin' && '-framework UniformTypeIdentifiers' || '' }}"
GOOS: ${{ matrix.GOOS }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLAB_CLIENT_SECRET: ${{ secrets.GITLAB_CLIENT_SECRET }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
GORELEASER_PREVIOUS_TAG: ${{ steps.release.outputs.prev }}

# Release binaries with GoReleaser
release:
runs-on: ubuntu-latest
needs: prepare
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
permissions:
Expand All @@ -84,26 +21,6 @@ jobs:
- uses: actions/[email protected]
with:
go-version-file: go.mod
- name: Copy Cache From Previous Job
shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Restore Linux Cache
uses: actions/[email protected]
with:
path: dist/linux
key: linux-${{ github.ref_name }}
- name: Restore Darwin Cache
uses: actions/[email protected]
with:
path: dist/darwin
key: darwin-${{ github.ref_name }}
- name: Restore Windows Cache
uses: actions/[email protected]
with:
path: dist/windows
key: windows-${{ github.ref_name }}
enableCrossOsArchive: true
- name: Get Previous Tag
id: prev
uses: WyriHaximus/github-action-get-previous-tag@v1
Expand All @@ -113,11 +30,10 @@ jobs:
uses: sigstore/[email protected]
- name: GoReleaser (Release)
uses: goreleaser/goreleaser-action@v6
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit
with:
distribution: goreleaser-pro
version: '~> v2'
args: continue --merge --timeout 90m
args: release --clean --timeout 90m
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
86 changes: 68 additions & 18 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# Requires a GoReleaser Pro to run
partial:
by: goos

version: 2

before:
Expand All @@ -18,9 +14,7 @@ builds:
- linux_amd64
- linux_arm64
- windows_amd64
# TODO: Re-enable once fixed
# Ref: https://github.com/golang/go/issues/51019
# - windows_arm64
- windows_arm64
- darwin_amd64
- darwin_arm64
env:
Expand All @@ -39,9 +33,7 @@ builds:
- linux_amd64
- linux_arm64
- windows_amd64
# TODO: Re-enable once fixed
# Ref: https://github.com/golang/go/issues/51019
# - windows_arm64
- windows_arm64
- darwin_amd64
- darwin_arm64
env:
Expand Down Expand Up @@ -169,11 +161,69 @@ brews:
test: |
system "#{bin}/plural", "--help"
# # Packages your package depends on.
# dependencies:
# - name: helm
# type: recommended
# - name: kubectl
# type: recommended
# - name: terraform
# type: recommended
- name: plrlctl
ids: [plrlctl]
repository:
owner: pluralsh
name: homebrew-plrlctl

# Optionally a branch can be provided.
# Defaults to the default repository branch.
branch: main

# Optionally a token can be provided, if it differs from the token provided to GoReleaser
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"

# Template for the url which is determined by the given Token (github, gitlab or gitea)
#
# Default depends on the client.
url_template: "https://github.com/pluralsh/plural-cli/releases/download/{{ .Tag }}/{{ .ArtifactName }}"

# Allows you to set a custom download strategy. Note that you'll need
# to implement the strategy and add it to your tap repository.
# Example: https://docs.brew.sh/Formula-Cookbook#specifying-the-download-strategy-explicitly
# Default is empty.
download_strategy: CurlDownloadStrategy

# Git author used to commit to the repository.
# Defaults are shown.
commit_author:
name: plural-bot
email: [email protected]

# The project name and current git tag are used in the format string.
commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"

# Folder inside the repository to put the formula.
# Default is the root folder.
directory: Formula

# Your app's homepage.
# Default is empty.
homepage: "https://docs.plural.sh"

# Template of your app's description.
# Default is empty.
description: "CLI to manage and operate a fleet of clusters"

# SPDX identifier of your app's license.
# Default is empty.
license: "MIT"

# Setting this will prevent goreleaser to actually try to commit the updated
# formula - instead, the formula file will be stored on the dist folder only,
# leaving the responsibility of publishing it to the user.
# If set to auto, the release will not be uploaded to the homebrew tap
# in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1
# Default is false.
skip_upload: "auto"

# Custom block for brew.
# Can be used to specify alternate downloads for devel or head releases.
# Default is empty.
custom_block: |
head "https://github.com/pluralsh/plural-cli.git"
test: |
system "#{bin}/plrlctl", "--help"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ release:

.PHONY: goreleaser
goreleaser:
goreleaser release --clean --prepare --single-target --snapshot --verbose
goreleaser build --clean --snapshot

.PHONY: setup
setup: ## sets up your local env (for mac only)
Expand Down

0 comments on commit 3b792d2

Please sign in to comment.