Skip to content

Commit 889ef1c

Browse files
authored
ci(releaser): add release ci (#551)
1 parent ad0cc81 commit 889ef1c

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Release releaser
2+
3+
on:
4+
push:
5+
tags:
6+
- "releaser-*" # Trigger on all tags
7+
8+
env:
9+
GO_VERSION: "1.25.0"
10+
PROJECT_NAME: "releaser"
11+
GITHUB_TOKEN: ${{ secrets.ARDUINOBOT_TOKEN }}
12+
GITHUB_USERNAME: ArduinoBot
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- name: Extract version
19+
shell: bash
20+
run: |
21+
TAG_NAME="${GITHUB_REF##*/}"
22+
VERSION="${TAG_NAME#releaser-}" # Remove 'releaser-' prefix
23+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
24+
echo "RELEASE_NAME=${{ env.PROJECT_NAME }}-${VERSION}-linux-amd64" >> $GITHUB_ENV
25+
env:
26+
GITHUB_REF: ${{ github.ref }}
27+
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Configure Git for private repo cloning
34+
run: |
35+
git config --global url."https://${{ env.GITHUB_USERNAME }}:${{ env.GITHUB_TOKEN }}@github.com".insteadOf "https://github.com"
36+
37+
- name: Set up Go
38+
uses: actions/setup-go@v5
39+
with:
40+
go-version: ${{ env.GO_VERSION }}
41+
42+
- name: Build Binary
43+
env:
44+
GOARCH: ${{ matrix.arch }}
45+
GOOS: ${{ matrix.os }}
46+
run: |
47+
mkdir -p build/
48+
go build -v -ldflags "-X 'main.version=${{ env.VERSION }}'" \
49+
-o ./build/ \
50+
./cmd/${{ env.PROJECT_NAME }}
51+
52+
- name: Prepare Build Artifacts
53+
run: |
54+
tar -czf ./build/${{ env.RELEASE_NAME }}.tar.gz -C ./build ${{ env.PROJECT_NAME }}
55+
56+
- name: Upload artifacts index
57+
uses: ncipollo/release-action@v1
58+
with:
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
draft: false
61+
prerelease: true
62+
artifacts: build/${{ env.RELEASE_NAME }}.tar.gz

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
tags:
66
- "*" # Trigger on all tags
77
- "!remoteocd-*" # Exclude remoteocd tags
8+
- "!releaser-*" # Exclude releaser tags
89

910
env:
1011
GO_VERSION: "1.24"

cmd/releaser/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import (
1111
"github.com/bcmi-labs/orchestrator/pkg/autoupdater/releaser"
1212
)
1313

14+
var version = "dev"
15+
1416
func main() {
1517
var (
18+
isVersion bool
1619
outputDir string
1720
platform releaser.Platform
1821
)
@@ -21,9 +24,15 @@ func main() {
2124

2225
flag.StringVar(&outputDir, "o", "public", "Output directory for writing updates")
2326
flag.Var(&platform, "platform", "Target platform in the form OS-ARCH. Defaults to running os/arch or the combination of the environment variables GOOS and GOARCH if both are set.")
27+
flag.BoolVar(&isVersion, "version", false, "Print the version of the releaser tool")
2428
flag.Usage = printUsage
2529
flag.Parse()
2630

31+
if isVersion {
32+
fmt.Println("Releaser version:", version)
33+
return
34+
}
35+
2736
if flag.NArg() < 2 {
2837
flag.Usage()
2938
os.Exit(1)

0 commit comments

Comments
 (0)