Skip to content

Commit 049b80f

Browse files
committed
Use goreleaser for building and pushing versions
1 parent 0afaf59 commit 049b80f

File tree

10 files changed

+134
-162
lines changed

10 files changed

+134
-162
lines changed

.github/workflows/ipxe_version.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: Update version string
2121
run: |
22-
sed -Ei 's/(IPXE_REF:) [0-9a-f]{40}/\1 ${{ steps.version.outputs.sha }}/' .github/workflows/ipxe_build.yaml
22+
sed -Ei 's/(IPXE_REF=)[0-9a-f]{40}/\1${{ steps.version.outputs.sha }}/' .goreleaser.yaml
2323
2424
- name: Create pull request
2525
uses: peter-evans/create-pull-request@v4

.github/workflows/pixie_image.yaml

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

.github/workflows/pixie_latest.yaml

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

.github/workflows/pixie_release.yaml

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

.github/workflows/release.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- '**'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
env:
16+
DOCKER_CLI_EXPERIMENTAL: enabled # needed for docker manifests
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0 # we need the entire history to build changelog
22+
23+
- name: Setup Go
24+
uses: actions/setup-go@v3
25+
with:
26+
go-version-file: go.mod
27+
28+
- name: Setup QEMU for cross-compiling container images
29+
uses: docker/setup-qemu-action@v2
30+
31+
- name: Setup Docker buildx
32+
uses: docker/setup-buildx-action@v2
33+
34+
- name: Authenticate with GHCR
35+
uses: docker/login-action@v2
36+
with:
37+
registry: ghcr.io
38+
username: ${{ github.repository_owner }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Install cross-compile dependencies
42+
run: |
43+
sudo apt update
44+
sudo apt install -y gcc-arm-none-eabi gcc-aarch64-linux-gnu
45+
46+
- name: Run goreleaser
47+
uses: goreleaser/goreleaser-action@v4
48+
with:
49+
args: release --rm-dist
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
REPOSITORY_OWNER: ${{ github.repository_owner }}

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
/bin/
2-
/ipxe/
3-
/pkg/tftp/*.efi
4-
/pkg/tftp/*.kpxe
1+
/pkg/tftp/ipxe/
2+
/dist/

.goreleaser.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
env:
2+
- IPXE_REF=d3c8944d5c3ab262826ed33b16f3fc4dd43bc304
3+
before:
4+
hooks:
5+
- rm -rf pkg/tftp/ipxe
6+
- git clone https://github.com/ipxe/ipxe pkg/tftp/ipxe
7+
- git -C pkg/tftp/ipxe checkout {{ .Env.IPXE_REF }}
8+
- make -C pkg/tftp/ipxe/src -j4 bin/undionly.kpxe
9+
bin-x86_64-efi/ipxe.efi
10+
bin-x86_64-efi/snponly.efi
11+
bin-i386-efi/ipxe.efi
12+
bin-i386-efi/snponly.efi
13+
- make -C pkg/tftp/ipxe/src -j4 CROSS=arm-none-eabi- ARCH=arm32 bin-arm32-efi/snponly.efi
14+
- make -C pkg/tftp/ipxe/src -j4 CROSS=aarch64-linux-gnu- ARCH=arm64 bin-arm64-efi/snponly.efi
15+
16+
builds:
17+
- main: ./cmd/pixie
18+
goos:
19+
- linux
20+
goarch:
21+
- amd64
22+
- arm64
23+
- arm
24+
env:
25+
- CGO_ENABLED=0
26+
27+
dockers:
28+
- goos: linux
29+
goarch: amd64
30+
dockerfile: Containerfile
31+
use: buildx
32+
build_flag_templates:
33+
- --platform=linux/amd64
34+
image_templates:
35+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Tag }}-amd64
36+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:latest-amd64
37+
38+
- goos: linux
39+
goarch: arm64
40+
dockerfile: Containerfile
41+
use: buildx
42+
build_flag_templates:
43+
- --platform=linux/arm64
44+
image_templates:
45+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Tag }}-arm64
46+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:latest-arm64
47+
48+
- goos: linux
49+
goarch: arm
50+
dockerfile: Containerfile
51+
use: buildx
52+
build_flag_templates:
53+
- --platform=linux/arm
54+
image_templates:
55+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Tag }}-arm32
56+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:latest-arm32
57+
58+
docker_manifests:
59+
- name_template: ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Tag }}
60+
image_templates:
61+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Tag }}-amd64
62+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Tag }}-arm64
63+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Tag }}-arm32
64+
65+
- name_template: ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:latest
66+
image_templates:
67+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:latest-amd64
68+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:latest-arm64
69+
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:latest-arm32

Containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM scratch
22

3-
COPY --chown=65536:65536 --chmod=0777 bin/pixie /
3+
COPY --chown=65536:65536 --chmod=0777 pixie /
44

55
# set default ports for rootless use
66
ENV TFTP :6969

cmd/pixie/cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/p3lim/pixie/pkg/tftp"
1212
)
1313

14-
var Version = "dev"
14+
var version = "dev"
1515

1616
type args struct {
1717
TFTP string `arg:"-t,env" default:"0.0.0.0:69" placeholder:"ADDR" help:"tftp server address and port"`
@@ -22,7 +22,7 @@ type args struct {
2222
}
2323

2424
func (args) Version() string {
25-
return fmt.Sprintf("pixie %s", Version)
25+
return fmt.Sprintf("pixie %s", version)
2626
}
2727

2828
func main() {

pkg/tftp/embed.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ import _ "embed"
55
// this will embed iPXE ROMs already present in the `ipxe` subdirectory relative to this file into
66
// variables during build time.
77

8-
//go:embed ipxe/bin/undionly.kpxe
8+
//go:embed ipxe/src/bin/undionly.kpxe
99
var undionly []byte
1010

11-
//go:embed ipxe/bin-x86_64-efi/ipxe.efi
11+
//go:embed ipxe/src/bin-x86_64-efi/ipxe.efi
1212
var ipxe64 []byte
1313

14-
//go:embed ipxe/bin-i386-efi/ipxe.efi
14+
//go:embed ipxe/src/bin-i386-efi/ipxe.efi
1515
var ipxe32 []byte
1616

17-
//go:embed ipxe/bin-x86_64-efi/snponly.efi
17+
//go:embed ipxe/src/bin-x86_64-efi/snponly.efi
1818
var snponly64 []byte
1919

20-
//go:embed ipxe/bin-i386-efi/snponly.efi
20+
//go:embed ipxe/src/bin-i386-efi/snponly.efi
2121
var snponly32 []byte
2222

23-
//go:embed ipxe/bin-arm64-efi/snponly.efi
23+
//go:embed ipxe/src/bin-arm64-efi/snponly.efi
2424
var snponly64arm []byte
2525

26-
//go:embed ipxe/bin-arm32-efi/snponly.efi
26+
//go:embed ipxe/src/bin-arm32-efi/snponly.efi
2727
var snponly32arm []byte
2828

2929
//go:embed chain.ipxe

0 commit comments

Comments
 (0)