Skip to content
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.
Ayake-QAware Apr 26, 2022
93851df
chore: add iml files to gitignore
aeimer Oct 17, 2023
9d256a7
feat: first try of goreleaser brew tap
aeimer Oct 18, 2023
735aa5b
feat: adapt config so it should work
aeimer Oct 20, 2023
4949473
feat: Almost final step
aeimer Oct 23, 2023
c3edd8e
fix: goreleaser completions
aeimer Oct 23, 2023
e41c582
feat: replace deprecated command
aeimer Oct 23, 2023
9c3dddf
feat: run cd in subshell
aeimer Oct 23, 2023
4dc0392
fix: remove completions for now
aeimer Oct 23, 2023
9336c2f
fix: ci
aeimer Oct 23, 2023
49ba1eb
fix: ci
aeimer Oct 23, 2023
13d328f
fix: ci - use .ProjectName
aeimer Oct 23, 2023
bbd5c8f
fix: ci - use .ProjectName
aeimer Oct 23, 2023
c13a365
debug: try GITHUB_TOKEN
aeimer Oct 23, 2023
9796619
fix: ci
aeimer Oct 23, 2023
480aac7
debug: revert github token
aeimer Oct 23, 2023
7a73444
debug: add lengt variable
aeimer 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"
aeimer Oct 24, 2023
2b28930
feat: add shellcheck to CI
aeimer Oct 24, 2023
f47e4ad
fix; shellcheck
aeimer Oct 24, 2023
b8ac1c2
fix: brew push
aeimer Oct 24, 2023
63f163f
feat(ci): write secret to file and use it
aeimer Oct 24, 2023
f9550fb
feat(ci): style improvement
aeimer Oct 24, 2023
47bf596
fix(ci): repo owner and name
aeimer Oct 24, 2023
294b920
fix(ci): add gorelaser check
aeimer Oct 24, 2023
3d1171b
fix(ci): git repo url
aeimer Oct 24, 2023
31f8004
feat(ci): remove GH TOKEN file write
aeimer Oct 24, 2023
6b5cae9
feat(ci): set skip_upload to auto as Formula should not be pushed to …
aeimer Oct 24, 2023
2042f45
fix(ci): style
aeimer Oct 24, 2023
b2d1ad5
fix(ci): name and url template
aeimer Oct 24, 2023
22d78ae
feat(ci): add system test
aeimer Oct 24, 2023
465bdb1
fix(ci): hopefully remove all non templated fields with tempaltes in it
aeimer Oct 24, 2023
5a4f2d5
fix(ci): adapt to brew requirements
aeimer Oct 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
external-sources=true
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading