Skip to content

Commit

Permalink
setup release process
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-cup committed Feb 7, 2025
1 parent 6870150 commit f4878d6
Show file tree
Hide file tree
Showing 4 changed files with 613 additions and 1 deletion.
82 changes: 82 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Release with GoReleaser

on:
push:
tags:
- "v*"

permissions:
contents: write # needed to create releases
packages: write # needed if you're publishing to GitHub Packages

jobs:
build-and-push-frontend:
name: Build and push frontend
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3.3.0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Log into registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ghcr.io/${{ github.repository }}-frontend
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build Docker image
id: build
uses: docker/build-push-action@v5.3.0
with:
context: .
file: frontend.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: |
type=gha
type=registry,ref=ghcr.io/${{ github.repository }}-frontend:buildcache
cache-to: |
type=gha,mode=max
type=registry,ref=ghcr.io/${{ github.repository }}-frontend:buildcache,mode=max
release:
# needs: build-and-push-frontend
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for changelog generation

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23.4"
cache: true

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 changes: 48 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: 2

before:
hooks:
- go mod tidy

builds:
- id: cli
main: ./cmd/cli
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:
- formats: [tar.gz]
name_template: >-
{{ .ProjectName }}-v{{ .Version }}-
{{- if and (eq .Arch "amd64") (eq .Os "darwin") }}x86_64-apple-darwin
{{- else if and (eq .Arch "arm64") (eq .Os "darwin") }}arm64-apple-darwin
{{- else if and (eq .Arch "amd64") (eq .Os "linux") }}x86_64-unknown-linux-musl
{{- else if and (eq .Arch "arm64") (eq .Os "linux") }}arm64-unknown-linux-musl
{{- else if and (eq .Arch "amd64") (eq .Os "windows") }}x86_64-pc-windows-msvc
{{- else if and (eq .Arch "arm64") (eq .Os "windows") }}arm64-pc-windows-msvc
{{- else }}{{ .Arch }}-{{ .Os }}{{ end }}
format_overrides:
- goos: windows
formats: [zip]

changelog:
use: github-native

checksum:
name_template: 'checksums.txt'

release:
prerelease: auto

name_template: "{{.ProjectName}} v{{.Version}}"

include_meta: true
2 changes: 1 addition & 1 deletion frontend.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN go build -o /usr/bin/railpack cmd/cli/main.go
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o /usr/bin/railpack cmd/cli/main.go

FROM alpine

Expand Down
Loading

0 comments on commit f4878d6

Please sign in to comment.