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
12 changes: 12 additions & 0 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ jobs:
- name: Checkout code
uses: actions/checkout@v6

# Inject the release tag into proto/openapi sources so that `make
# generate` inside the Dockerfile bakes the right version into the
# OpenAPI spec served at `/`. The server binary's `version` var is
# overridden separately via ldflags (see Dockerfile `ARG VERSION`).
- name: Inject release version into proto openapi annotations
env:
VERSION: ${{ github.ref_name }}
run: |
sed -i "s/version: \"dev\";/version: \"${VERSION}\";/" proto/milpacs.proto proto/tickets.proto

- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
Expand All @@ -23,6 +33,8 @@ jobs:
with:
context: .
push: true
build-args: |
VERSION=${{ github.ref_name }}
tags: |
7cav/api:${{ github.ref_name }}
7cav/api:latest
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
RUN go mod tidy
RUN go build -a -ldflags="-s -w" -installsuffix cgo -o /api

# VERSION is supplied by the release workflow via --build-arg from
# the GitHub release tag (`github.ref_name`). Defaults to "dev" for
# local docker builds so `Starting 7Cav API version:` shows something
# meaningful even without the tag flow.
ARG VERSION=dev
RUN go build -a -ldflags="-s -w -X github.com/7cav/api/servers.version=${VERSION}" -installsuffix cgo -o /api

# Production stage
FROM alpine:latest
Expand Down
2 changes: 1 addition & 1 deletion proto/milpacs.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto/milpacs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import "google/protobuf/empty.proto";
// These annotations are used when generating the OpenAPI file.
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
version: "2.2.0";
version: "dev";
};
external_docs: {
url: "https://github.com/7cav/api";
Expand Down
4 changes: 2 additions & 2 deletions proto/tickets.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto/tickets.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import "google/protobuf/empty.proto";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "7Cav Tickets API";
version: "2.2.0";
version: "dev";
description: "Read-only access to 7Cav forum tickets (nixfifty addon).";
}
schemes: HTTPS;
Expand Down
5 changes: 4 additions & 1 deletion servers/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ import (
"gorm.io/gorm"
)

const version = "2.2.0"
// version is overridden at build time via -ldflags
// "-X github.com/7cav/api/servers.version=<tag>" in the release workflow.
// Local dev builds report "dev".
var version = "dev"

type MicroServer struct {
addr string
Expand Down
2 changes: 1 addition & 1 deletion statik/statik.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion third_party/OpenAPI/milpacs.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"swagger": "2.0",
"info": {
"title": "milpacs.proto",
"version": "2.2.0"
"version": "dev"
},
"tags": [
{
Expand Down
2 changes: 1 addition & 1 deletion third_party/OpenAPI/tickets.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "7Cav Tickets API",
"description": "Read-only access to 7Cav forum tickets (nixfifty addon).",
"version": "2.2.0"
"version": "dev"
},
"tags": [
{
Expand Down