-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (78 loc) · 2.58 KB
/
Copy pathbuild-packages.yml
File metadata and controls
90 lines (78 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Build binary packages
on:
push:
branches:
- master
- main
pull_request:
release:
types: [published]
workflow_dispatch:
env:
GOBGP_VERSION: 3.14.0
jobs:
build-packages:
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build country_lockdown binary
run: |
mkdir -p bin dist
CGO_ENABLED=0 GOOS=linux GOARCH=${{ matrix.arch }} go build -mod=vendor -o bin/country_lockdown .
- name: Download gobgp tools
run: |
wget "https://github.com/osrg/gobgp/releases/download/v${GOBGP_VERSION}/gobgp_${GOBGP_VERSION}_linux_${{ matrix.arch }}.tar.gz" -O /tmp/gobgp.tar.gz
tar -xf /tmp/gobgp.tar.gz -C bin/
- name: Install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.42.0
- name: Build deb/rpm packages
run: |
cp nfpm.yaml "${RUNNER_TEMP}/nfpm.yaml"
sed -i -E 's/^arch:[[:space:]]*".*"/arch: "${{ matrix.arch }}"/' "${RUNNER_TEMP}/nfpm.yaml"
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION="${{ github.event.release.tag_name }}"
sed -i -E "s/^version:[[:space:]]*\".*\"/version: \"${VERSION}\"/" "${RUNNER_TEMP}/nfpm.yaml"
fi
~/go/bin/nfpm pkg --config "${RUNNER_TEMP}/nfpm.yaml" --packager deb --target dist/
~/go/bin/nfpm pkg --config "${RUNNER_TEMP}/nfpm.yaml" --packager rpm --target dist/
- name: Upload package artifacts
uses: actions/upload-artifact@v4
with:
name: country-lockdown-packages-${{ matrix.arch }}
path: dist/*
if-no-files-found: error
upload-release-assets:
if: github.event_name == 'release'
needs: build-packages
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all package artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Upload assets to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
for file in dist/*.deb dist/*.rpm; do
echo "Uploading ${file}..."
gh release upload "${{ github.event.release.tag_name }}" "$file" --clobber
done