Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

on:
pull_request:
branches:
- main
push:
branches:
- main

permissions:
contents: read

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Set up Just
uses: extractions/setup-just@v3

- name: Run tests
run: just test

cross-build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Set up Just
uses: extractions/setup-just@v3

- name: Validate cross-platform builds
run: just clean && just build-all
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release

on:
push:
tags:
- "*"
- "*/*"

permissions:
contents: write

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true

jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Set up Just
uses: extractions/setup-just@v3

- name: Build release binaries
run: just clean && VERSION="${GITHUB_REF_NAME}" just build-all

- name: Package release artifacts
shell: bash
run: |
mkdir -p release
for file in dist/*; do
base="$(basename "$file")"
stem="${base%.exe}"
versioned="${stem}-${GITHUB_REF_NAME}"
if [[ "$base" == *.exe ]]; then
zip -j "release/${versioned}.zip" "$file"
continue
fi
tar -C dist -czf "release/${versioned}.tar.gz" "$base"
done
(
cd release
sha256sum * > checksums.txt
)

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
files: release/*
fail_on_unmatched_files: true
generate_release_notes: true
31 changes: 0 additions & 31 deletions Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Current scope:
## Build

```bash
make build
make build-all
just build
just build-all
```

Artifacts are written to `dist/`.
Expand Down
35 changes: 35 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
set shell := ["bash", "-eu", "-o", "pipefail", "-c"]

module := "github.com/formation-res/open-location-hub-cli"
binary := env_var_or_default("BINARY", "olh")
dist := env_var_or_default("DIST", "dist")
version := env_var_or_default("VERSION", `git describe --tags --always --dirty 2>/dev/null || echo dev`)
commit := env_var_or_default("COMMIT", `git rev-parse --short HEAD 2>/dev/null || echo unknown`)
date := env_var_or_default("DATE", `date -u +"%Y-%m-%dT%H:%M:%SZ"`)
default:
@just --list

generate:
go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.4.1 -config internal/openapi/client.cfg.yaml api/omlox-hub.v0.yaml

tidy:
go mod tidy

build: generate
mkdir -p {{dist}}
go build -ldflags "-s -w -X {{module}}/internal/build.Version={{version}} -X {{module}}/internal/build.Commit={{commit}} -X {{module}}/internal/build.Date={{date}}" -o {{dist}}/{{binary}} ./cmd/olh

test: generate
go test ./...

clean:
rm -rf {{dist}}

build-all: generate
mkdir -p {{dist}}
GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X {{module}}/internal/build.Version={{version}} -X {{module}}/internal/build.Commit={{commit}} -X {{module}}/internal/build.Date={{date}}" -o {{dist}}/{{binary}}-darwin-amd64 ./cmd/olh
GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -X {{module}}/internal/build.Version={{version}} -X {{module}}/internal/build.Commit={{commit}} -X {{module}}/internal/build.Date={{date}}" -o {{dist}}/{{binary}}-darwin-arm64 ./cmd/olh
GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X {{module}}/internal/build.Version={{version}} -X {{module}}/internal/build.Commit={{commit}} -X {{module}}/internal/build.Date={{date}}" -o {{dist}}/{{binary}}-linux-amd64 ./cmd/olh
GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X {{module}}/internal/build.Version={{version}} -X {{module}}/internal/build.Commit={{commit}} -X {{module}}/internal/build.Date={{date}}" -o {{dist}}/{{binary}}-linux-arm64 ./cmd/olh
GOOS=windows GOARCH=386 go build -ldflags "-s -w -X {{module}}/internal/build.Version={{version}} -X {{module}}/internal/build.Commit={{commit}} -X {{module}}/internal/build.Date={{date}}" -o {{dist}}/{{binary}}-windows-386.exe ./cmd/olh
GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X {{module}}/internal/build.Version={{version}} -X {{module}}/internal/build.Commit={{commit}} -X {{module}}/internal/build.Date={{date}}" -o {{dist}}/{{binary}}-windows-amd64.exe ./cmd/olh
Loading