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
50 changes: 50 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
push:
tags:
- "v*"

permissions:
contents: write
packages: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Install mise
uses: jdx/mise-action@v2

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

- name: Run tests
run: mise run test

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: release-artifacts
path: |
dist/
!dist/*.txt
retention-days: 30
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ coverage.html

# VSCode settings (user-specific)
.vscode/*
!.vscode/settings.example.json
!.vscode/settings.example.json
# Added by goreleaser init:
dist/
102 changes: 102 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy

builds:
- id: openapi-cli
main: ./cmd/openapi
binary: openapi
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ldflags:
- -s -w
- -X main.version={{.Version}}
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}

archives:
- id: openapi-cli
formats: [tar.gz]
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
formats: [zip]
files:
- README.md
- LICENSE*

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
- "^chore:"
- "^ci:"
groups:
- title: Features
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 0
- title: Bug fixes
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 1
- title: Others
order: 999

release:
github:
owner: speakeasy-api
name: openapi
draft: false
prerelease: auto
mode: replace
header: |
## OpenAPI CLI {{ .Tag }}

This release includes binaries for Linux, macOS, and Windows on both x86_64 and ARM64 architectures.

### Installation

Download the appropriate binary for your platform from the assets below, extract it, and add it to your PATH.

### Changes
footer: |

---

**Full Changelog**: https://github.com/speakeasy-api/openapi/compare/{{ .PreviousTag }}...{{ .Tag }}

Released by [GoReleaser](https://github.com/goreleaser/goreleaser).

# Generate checksums for all artifacts
checksum:
name_template: "checksums.txt"
# Generate Software Bill of Materials (SBOM)
sboms:
- artifacts: archive
12 changes: 10 additions & 2 deletions cmd/openapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

var (
version = "dev"
commit = "none"
date = "unknown"
)

var rootCmd = &cobra.Command{
Expand Down Expand Up @@ -72,8 +74,14 @@ These commands help you validate and work with Arazzo documents.`,
}

func init() {
// Set version template
rootCmd.SetVersionTemplate(`{{printf "%s" .Version}}`)
// Set version template with build info
if commit != "none" && date != "unknown" {
rootCmd.SetVersionTemplate(`{{printf "%s" .Version}}
Build: ` + commit + `
Built: ` + date)
} else {
rootCmd.SetVersionTemplate(`{{printf "%s" .Version}}`)
}

// Add OpenAPI spec validation command
openapiCmd.Apply(openapiCmds)
Expand Down
Loading