-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Build from a matrix of platform-arch pairs - Add helper function to automate cross-compilation - Add PLATFORMS to platforms.bzl identifying what to build for - Create a new release on tags
- Loading branch information
Showing
5 changed files
with
75 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build & Release | ||
run-name: Build & Release | ||
on: push | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
goos: [linux, darwin] | ||
goarch: [arm64, amd64] | ||
runs-on: ${{ matrix.goos }} | ||
steps: | ||
- name: Check out smart-dns-updater | ||
uses: actions/checkout@v4 | ||
- run: | | ||
bazelisk build //:smart-dns-updater_${{ matrix.goos }}_${{ matrix.goarch }} | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: smart-dns-updater_${{ matrix.goos }}_${{ matrix.goarch }} | ||
path: bazel-bin/smart-dns-updater_${{ matrix.goos }}_${{ matrix.goarch }}_/smart-dns-updater_${{ matrix.goos }}_${{ matrix.goarch }} | ||
if-no-files-found: error | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Release | ||
uses: softprops/action-gh-release@v2 | ||
# Only release on tags | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: | | ||
bazel-bin/smart-dns-updater_*_/smart-dns-updater_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Helper module to create binaries per PLATFORM-ARCH combination""" | ||
|
||
load("@rules_go//go:def.bzl", "go_binary") | ||
|
||
# Function to create a go_binary target for each platform-arch combination | ||
def cross_compile_binary(name, goos, goarch): | ||
go_binary( | ||
name = "{}_{}_{}".format(name, goos, goarch), | ||
embed = [":{}_lib".format(name)], | ||
goarch = goarch, | ||
goos = goos, | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""Define platform, arch pairs to build""" | ||
|
||
# Define the matrix of platforms and architectures | ||
PLATFORMS = [ | ||
("linux", "amd64"), | ||
("linux", "arm64"), | ||
("darwin", "amd64"), | ||
("darwin", "arm64"), | ||
] |