Skip to content

Commit f0d3281

Browse files
authored
Release workflow for worker binaries (#30)
1 parent 3d0c2d0 commit f0d3281

5 files changed

Lines changed: 112 additions & 2 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build Release
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
7+
jobs:
8+
build:
9+
name: "Build ${{ matrix.goos }} ${{ matrix.goarch }}"
10+
runs-on: namespace-profile-ubuntu-small
11+
strategy:
12+
matrix:
13+
include:
14+
- goos: linux
15+
goarch: amd64
16+
- goos: linux
17+
goarch: arm64
18+
- goos: darwin
19+
goarch: amd64
20+
- goos: darwin
21+
goarch: arm64
22+
- goos: windows
23+
goarch: amd64
24+
- goos: windows
25+
goarch: arm64
26+
steps:
27+
- name: Check out repository
28+
uses: actions/checkout@v6
29+
30+
- name: Install Go
31+
uses: actions/setup-go@v6
32+
with:
33+
go-version-file: 'go.mod'
34+
# Use the Namespace Go cache
35+
cache: false
36+
37+
- name: Set up build cache
38+
uses: namespacelabs/nscloud-cache-action@v1
39+
with:
40+
cache: go
41+
42+
- name: Build
43+
env:
44+
CGO_ENABLED: '0'
45+
GOOS: ${{ matrix.goos }}
46+
GOARCH: ${{ matrix.goarch }}
47+
run: |
48+
binary="oz-agent-worker"
49+
if [ "$GOOS" = "windows" ]; then
50+
binary="oz-agent-worker.exe"
51+
fi
52+
go build -o "$binary" .
53+
54+
- name: Archive
55+
run: |
56+
prefix="oz-agent-worker-${{ matrix.goos }}-${{ matrix.goarch }}"
57+
if [ "${{ matrix.goos }}" = "windows" ]; then
58+
zip "${prefix}.zip" oz-agent-worker.exe
59+
else
60+
tar czf "${prefix}.tar.gz" oz-agent-worker
61+
tar cJf "${prefix}.tar.xz" oz-agent-worker
62+
fi
63+
64+
- name: Upload artifact
65+
uses: namespace-actions/upload-artifact@v1
66+
with:
67+
name: oz-agent-worker-${{ matrix.goos }}-${{ matrix.goarch }}
68+
path: |
69+
oz-agent-worker-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
70+
oz-agent-worker-${{ matrix.goos }}-${{ matrix.goarch }}.tar.xz
71+
oz-agent-worker-${{ matrix.goos }}-${{ matrix.goarch }}.zip
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
9+
uses: ./.github/workflows/build_release.yml
10+
11+
release:
12+
needs: build
13+
runs-on: namespace-profile-ubuntu-small
14+
permissions:
15+
contents: write
16+
steps:
17+
- name: Generate tag name
18+
id: tag
19+
run: echo "name=v$(date -u +'%Y-%m-%d-%H-%M-%S')" >> "$GITHUB_OUTPUT"
20+
21+
- name: Download artifacts
22+
uses: namespace-actions/download-artifact@v1
23+
with:
24+
path: artifacts
25+
26+
- name: Create release
27+
uses: softprops/action-gh-release@v2
28+
with:
29+
tag_name: ${{ steps.tag.outputs.name }}
30+
target_commitish: ${{ github.sha }}
31+
generate_release_notes: true
32+
files: artifacts/**/*

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM golang:1.25-alpine AS builder
2+
FROM golang:1.26-alpine AS builder
33

44
WORKDIR /app
55

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/warpdotdev/oz-agent-worker
22

3-
go 1.25.0
3+
go 1.26.0
44

55
require (
66
github.com/alecthomas/kong v1.13.0

script/test-build-release-workflow

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
# Dry-run the build_release workflow locally using nektos/act.
3+
# Usage: script/test-build-release-workflow
4+
5+
set -euo pipefail
6+
7+
act workflow_dispatch -W .github/workflows/build_release.yml --container-architecture linux/amd64 -P namespace-profile-ubuntu-small=catthehacker/ubuntu:act-latest "$@"

0 commit comments

Comments
 (0)