Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

32 provide mac homebrew for protocurl #42

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c6de30a
Work in progress.
qa-swaneet-sahoo Apr 26, 2022
93851df
chore: add iml files to gitignore
qa-alexander-eimer Oct 17, 2023
9d256a7
feat: first try of goreleaser brew tap
qa-alexander-eimer Oct 18, 2023
735aa5b
feat: adapt config so it should work
qa-alexander-eimer Oct 20, 2023
4949473
feat: Almost final step
qa-alexander-eimer Oct 23, 2023
c3edd8e
fix: goreleaser completions
qa-alexander-eimer Oct 23, 2023
e41c582
feat: replace deprecated command
qa-alexander-eimer Oct 23, 2023
9c3dddf
feat: run cd in subshell
qa-alexander-eimer Oct 23, 2023
4dc0392
fix: remove completions for now
qa-alexander-eimer Oct 23, 2023
9336c2f
fix: ci
qa-alexander-eimer Oct 23, 2023
49ba1eb
fix: ci
qa-alexander-eimer Oct 23, 2023
13d328f
fix: ci - use .ProjectName
qa-alexander-eimer Oct 23, 2023
bbd5c8f
fix: ci - use .ProjectName
qa-alexander-eimer Oct 23, 2023
c13a365
debug: try GITHUB_TOKEN
qa-alexander-eimer Oct 23, 2023
9796619
fix: ci
qa-alexander-eimer Oct 23, 2023
480aac7
debug: revert github token
qa-alexander-eimer Oct 23, 2023
7a73444
debug: add lengt variable
qa-alexander-eimer Oct 23, 2023
16d39d3
export qaware/tap token to goreleaser
GollyTicker Oct 23, 2023
9ee365b
better variant
GollyTicker Oct 23, 2023
d7343e6
Revert "debug: add lengt variable"
qa-alexander-eimer Oct 24, 2023
2b28930
feat: add shellcheck to CI
qa-alexander-eimer Oct 24, 2023
f47e4ad
fix; shellcheck
qa-alexander-eimer Oct 24, 2023
b8ac1c2
fix: brew push
qa-alexander-eimer Oct 24, 2023
63f163f
feat(ci): write secret to file and use it
qa-alexander-eimer Oct 24, 2023
f9550fb
feat(ci): style improvement
qa-alexander-eimer Oct 24, 2023
47bf596
fix(ci): repo owner and name
qa-alexander-eimer Oct 24, 2023
294b920
fix(ci): add gorelaser check
qa-alexander-eimer Oct 24, 2023
3d1171b
fix(ci): git repo url
qa-alexander-eimer Oct 24, 2023
31f8004
feat(ci): remove GH TOKEN file write
qa-alexander-eimer Oct 24, 2023
6b5cae9
feat(ci): set skip_upload to auto as Formula should not be pushed to …
qa-alexander-eimer Oct 24, 2023
2042f45
fix(ci): style
qa-alexander-eimer Oct 24, 2023
b2d1ad5
fix(ci): name and url template
qa-alexander-eimer Oct 24, 2023
22d78ae
feat(ci): add system test
qa-alexander-eimer Oct 24, 2023
465bdb1
fix(ci): hopefully remove all non templated fields with tempaltes in it
qa-alexander-eimer Oct 24, 2023
5a4f2d5
fix(ci): adapt to brew requirements
qa-alexander-eimer Oct 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/release.yml
Expand Up @@ -60,11 +60,15 @@ jobs:
- name: Build Archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN_QAWARE_TAP_REPO: ${{ secrets.GH_TOKEN_QAWARE_TAP_REPO }}
run: |
export PATH=$PATH:/usr/local/go/bin
export GORELEASER_CURRENT_TAG="v${{ github.event.inputs.version }}"
export GORELEASER_PREVIOUS_TAG="${{ env.GORELEASER_PREVIOUS_TAG }}"
PATH=$PATH:/usr/local/go/bin
GORELEASER_CURRENT_TAG="v${{ github.event.inputs.version }}"
GORELEASER_PREVIOUS_TAG="${{ env.GORELEASER_PREVIOUS_TAG }}"
export PATH GORELEASER_CURRENT_TAG GORELEASER_PREVIOUS_TAG
echo "$GH_TOKEN_QAWARE_TAP_REPO" > /tmp/GH_TOKEN_QAWARE_TAP_REPO
./release/30-build-go-archive.sh
rm -rf /tmp/GH_TOKEN_QAWARE_TAP_REPO

- name: DockerHub Login
uses: docker/login-action@v3
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -14,6 +14,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master

- name: Setup
run: |
sudo apt-get -q update
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Expand Up @@ -33,8 +33,8 @@ node_modules/

# IntelliJ
.idea
*.iml

# GoReleaser
dist/
# template output
.goreleaser.yaml
/dist/
/completions/
155 changes: 155 additions & 0 deletions .goreleaser.yaml
@@ -0,0 +1,155 @@
# Documentation at https://goreleaser.com

before:
hooks: []
# - ./release/completions.sh # TODO: Fix completions build

# https://goreleaser.com/customization/build/
builds:
- binary: bin/protocurl
dir: src
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
ignore:
# This combination is not pre-built by Google Protobuf
- goos: windows
goarch: arm64


# https://goreleaser.com/customization/archive/
archives:
- format: zip
files:
# NOTE: These files are listed again in the packages below. Keep them synced!
# binary is added implicitly
- README.md
- LICENSE.md
# - completions/* ' TODO: Fix completions build
# copy protoc binaries and their .proto files previously downloaded
- src: 'release/tmp/protoc-{{ .Env.PROTO_VERSION }}-{{ .Os }}-{{ .Arch }}/bin'
dst: 'protocurl-internal/bin'
strip_parent: true # avoids, that protoc is copied into protocurl-internal/bin/release/tmp/.../bin
- src: 'release/tmp/protoc-{{ .Env.PROTO_VERSION }}-{{ .Os }}-{{ .Arch }}/include/google/protobuf'
dst: 'protocurl-internal/include/google/protobuf'
strip_parent: true

# Linux packages
nfpms:
- package_name: "{{ .ProjectName }}"
description: |-
protoCURL is cURL for Protobuf:
The command-line tool for interacting with Protobuf over
HTTP REST endpoints using human-readable text formats.

homepage: https://github.com/qaware/{{ .ProjectName }}
license: MIT
maintainer: GollyTicker <golly.ticker@gmail.com>
priority: extra

formats:
- apk
- deb
dependencies:
- curl
suggests:
- curl

overrides:
# protoc is compiled against glibc whereas alpine uses musl.
# See: https://stackoverflow.com/a/64447927
apk:
dependencies:
- curl
- gcompat

# adds the ./bin/protocurl
bindir: "/opt/protocurl"

# GoReleaser will automatically add the binaries.
contents:
- src: /opt/protocurl/bin/protocurl
dst: /usr/bin/protocurl
type: "symlink"

# NOTE: These files are listed again in the archives above. Keep them synced!
# binary is added implicitly
- src: README.md
dst: /opt/protocurl/README.md
- src: LICENSE.md
dst: /opt/protocurl/LICENSE.md
# copy protoc binaries and their .proto files previously downloaded
- src: 'release/tmp/protoc-{{ .Env.PROTO_VERSION }}-{{ .Os }}-{{ .Arch }}/bin'
dst: '/opt/protocurl/protocurl-internal/bin'
- src: 'release/tmp/protoc-{{ .Env.PROTO_VERSION }}-{{ .Os }}-{{ .Arch }}/include/google/protobuf'
dst: '/opt/protocurl/protocurl-internal/include/google/protobuf'
# Completions
# TODO: Fix completions build
# - src: ./completions/{{ .ProjectName }}.bash
# dst: /usr/share/bash-completion/completions/{{ .ProjectName }}
# file_info:
# mode: 0644
# - src: ./completions/{{ .ProjectName }}.fish
# dst: /usr/share/fish/vendor_completions.d/{{ .ProjectName }}.fish
# file_info:
# mode: 0644
# - src: ./completions/{{ .ProjectName }}.zsh
# dst: /usr/share/zsh/vendor-completions/_{{ .ProjectName }}
# file_info:
# mode: 0644

brews:
# We will deploy always the latest
- &brew
name: "{{ .ProjectName }}"
homepage: https://gitlab.com/qaware/protocurl
description: >-
protoCURL is cURL for Protobuf:
The command-line tool for interacting with Protobuf over
HTTP REST endpoints using human-readable text formats.
license: MIT
url_template: "https://github.com/qaware/protocurl/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
skip_upload: auto
# GitHub/GitLab repository to push the formula to
repository:
owner: qaware
name: homebrew-tap
branch: main
git:
url: git@github.com:qaware/homebrew-tap.git
private_key: /tmp/GH_TOKEN_QAWARE_TAP_REPO
folder: Formula
dependencies:
- name: curl
install: |-
bin.install "{{ .ProjectName }}"
# TODO: Make completion build run
# bash_completion.install "completions/{{ .ProjectName }}.bash" => "{{ .ProjectName }}"
# zsh_completion.install "completions/{{ .ProjectName }}.zsh" => "_{{ .ProjectName }}"
# fish_completion.install "completions/{{ .ProjectName }}.fish"
test: |
system "#{bin}/{{ .ProjectName }} --version"
# Additionally Major is deployed to offer older versions
- <<: *brew
name: "{{ .ProjectName }}@{{ .Major }}"

release:
# If set to auto, will mark the release as not ready for production
# in case there is an indicator for this in the tag e.g. v1.0.0-rc1
prerelease: auto

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Version }}-dev"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
1 change: 1 addition & 0 deletions .shellcheckrc
@@ -0,0 +1 @@
external-sources=true
2 changes: 1 addition & 1 deletion RELEASE.md
Expand Up @@ -3,7 +3,7 @@
We use [GoReleaser](https://goreleaser.com/) to create static binaries and Docker Buildx to build multi-architecture
images.

The relevant configuration for the release process is in [template.goreleaser.yml](template.goreleaser.yaml)
The relevant configuration for the release process is in [.goreleaser.yml](.goreleaser.yaml)
and [release/source.sh](release/source.sh). It **automatically** fetches the **latest** Go, Goreleaser and Protobuf
versions via GitHub API.

Expand Down
2 changes: 1 addition & 1 deletion dev/generate-local.Dockerfile.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

# Concatenate the dev dockerfile and the final release dockerfile to get the combined one
Expand Down
6 changes: 3 additions & 3 deletions doc/generate-docs.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

WORKING_DIR="$1"
Expand Down Expand Up @@ -212,8 +212,8 @@ echo "Generating README.md..."
README_TEMPLATE="$(cat doc/template.README.md)"

# replacements ============================
echo "$README_TEMPLATE" |
sed "s%___EXAMPLE_1_OUT___%$EXAMPLE_1_OUT%" >README.md
# shellcheck disable=SC2001
sed "s%___EXAMPLE_1_OUT___%$EXAMPLE_1_OUT%" >README.md <<<"$README_TEMPLATE"

normaliseOutput README.md

Expand Down
5 changes: 3 additions & 2 deletions release/0-get-latest-dependencies-versions.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

LATEST_VERSION=""
Expand All @@ -23,6 +23,7 @@ retrieveLatestVersion() {
REPO="$2"
TAG_FILTER="$3"

# shellcheck disable=SC2001
FILE_FRIENDLY_NAME="$(echo "$REPO" | sed 's#/#.#g')"

CACHE_FILE="release/.cache/$FILE_FRIENDLY_NAME.cache.json"
Expand Down Expand Up @@ -51,7 +52,7 @@ retrieveLatestVersion() {
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$REPO/$ENDPOINT")"

STATUS_CODE_LINE="$(cat "$HEADERS_FILE" | head -n 1)"
STATUS_CODE_LINE="$(head -n 1 < "$HEADERS_FILE")"

if [[ "$STATUS_CODE_LINE" == *" 200"* ]]; then
echo "Populating cache..."
Expand Down
4 changes: 2 additions & 2 deletions release/10-ensure-protoc-binaries-exist.sh
@@ -1,10 +1,10 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

source ./release/0-get-latest-dependencies-versions.sh

FILES_EXIST="true"
ls release/tmp/protoc-$PROTO_VERSION-*.zip > /dev/null 2>&1 || FILES_EXIST="false"
ls release/tmp/protoc-"$PROTO_VERSION"-*.zip > /dev/null 2>&1 || FILES_EXIST="false"

if [[ "$FILES_EXIST" == "true" ]]; then
echo "Found protoc binaries for $PROTO_VERSION."
Expand Down
2 changes: 1 addition & 1 deletion release/10.1-get-protoc-binaries.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

# platforms and architectures for which Google released pre-built binaries
Expand Down
2 changes: 1 addition & 1 deletion release/100-check-latest-versions.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

SAVED="release/versions.txt"
Expand Down
2 changes: 1 addition & 1 deletion release/101-save-latest-versions.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

# See RELEASE.md
Expand Down
2 changes: 1 addition & 1 deletion release/20-install-go.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail
set -x

Expand Down
8 changes: 3 additions & 5 deletions release/30-build-go-archive.sh
@@ -1,11 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

source release/source.sh

cp template.goreleaser.yaml .goreleaser.yaml
sed -i "s/__PROTO_VERSION__/$PROTO_VERSION/g" .goreleaser.yaml

set -x

goreleaser check
Expand All @@ -14,9 +11,10 @@ echo "Using GORELEASER_CURRENT_TAG=$GORELEASER_CURRENT_TAG, GORELEASER_PREVIOUS_

GORELEASER_ARGS=""
if [[ "$SNAPSHOT" == "true" ]]; then
GORELEASER_ARGS="--skip-announce"
GORELEASER_ARGS="--skip=announce"
fi

goreleaser check
goreleaser release --clean $GORELEASER_ARGS

# Alternate commands when testing release process locally
Expand Down
2 changes: 1 addition & 1 deletion release/40-generate-Dockerfile.sh
@@ -1,3 +1,3 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail
cat release/builder.Dockerfile <(echo "# ==================") release/final.Dockerfile >release/generated.Dockerfile
10 changes: 10 additions & 0 deletions release/completions.sh
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# https://carlosbecker.com/posts/golang-completions-cobra/
set -e

rm -rf completions
mkdir completions

for sh in bash zsh fish; do
go run -C src protocurl.go completion "$sh" >"completions/protocurl.$sh"
done
5 changes: 3 additions & 2 deletions release/source.sh
@@ -1,12 +1,13 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

# PRECONDITION: git fetch origin --tags

source ./release/10-ensure-protoc-binaries-exist.sh

# should be one of 386, amd64 and arm64
export BUILD_ARCH="$(uname -m | sed "s/x86_64/amd64/" | sed "s/x86_32/386/" | sed "s/aarch_64/arm64/")"
BUILD_ARCH="$(uname -m | sed "s/x86_64/amd64/" | sed "s/x86_32/386/" | sed "s/aarch_64/arm64/")"
export BUILD_ARCH

# ensure, that 1.2.3-rc < 1.2.3, since the opposite is the default
git config versionsort.suffix -
Expand Down