Skip to content

Commit 8c53281

Browse files
authored
feat: goreleaser action (#12)
1 parent 3a36e5c commit 8c53281

4 files changed

Lines changed: 110 additions & 113 deletions

File tree

.github/workflows/build.yaml

Lines changed: 0 additions & 112 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags like v1.0.0
7+
workflow_dispatch:
8+
9+
jobs:
10+
release:
11+
name: Run GoReleaser
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
packages: write
16+
17+
steps:
18+
# Checkout the code
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
# Set up Go environment
25+
- name: Set up Go
26+
uses: actions/setup-go@v4
27+
with:
28+
go-version: 1.24
29+
30+
# Set up Docker Buildx
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
# Login to GitHub Container Registry
35+
- name: Login to GitHub Container Registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
# Install GoReleaser
43+
- name: Install GoReleaser
44+
uses: goreleaser/goreleaser-action@v4
45+
with:
46+
version: latest
47+
48+
# Run GoReleaser
49+
- name: Run GoReleaser
50+
run: goreleaser release --clean
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
54+
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
55+

.goreleaser.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# GoReleaser configuration file
2+
3+
# General settings
4+
project_name: chargeflow
5+
builds:
6+
- id: cli
7+
main: ./main.go
8+
binary: chargeflow
9+
goos:
10+
- freebsd
11+
- windows
12+
- darwin
13+
- linux
14+
goarch:
15+
- amd64
16+
- arm64
17+
- arm
18+
19+
archives:
20+
- id: cli-archive
21+
format: tar.gz
22+
files:
23+
- LICENSE.md
24+
- README.md
25+
26+
dockers:
27+
- image_templates:
28+
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/chargeflow:{{ .Version }}"
29+
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/chargeflow:latest"
30+
dockerfile: ./build/Dockerfile
31+
platforms:
32+
- linux/amd64
33+
- linux/arm64
34+
use: buildx
35+
build_flag_templates:
36+
- "--pull"
37+
- "--label=org.opencontainers.image.title=chargeflow"
38+
- "--label=org.opencontainers.image.description=CLI tool for analyzing OCPP JSON messages"
39+
- "--label=org.opencontainers.image.version={{ .Version }}"
40+
- "--label=org.opencontainers.image.revision={{ .Commit }}"
41+
42+
release:
43+
github:
44+
owner: ${{ .Env.GITHUB_REPOSITORY_OWNER }}
45+
name: ${{ .Env.GITHUB_REPOSITORY_NAME }}
46+
draft: false
47+
prerelease: false
48+
49+
changelog:
50+
sort: asc
51+
filters:
52+
exclude:
53+
- '**/*.md'
54+

build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN go mod verify
1515
# Copy the rest of the source code
1616
COPY . .
1717

18-
RUN --mount=type=cache,target="/root/.cache/go-build" go build -o ./chargeflow ./cmd
18+
RUN --mount=type=cache,target="/root/.cache/go-build" go build -o ./chargeflow .
1919

2020
FROM debian:buster-slim as app
2121

0 commit comments

Comments
 (0)