Skip to content

Commit 0726e53

Browse files
wojcik91Maciej Wójcik
and
Maciej Wójcik
authored
ci: build release binaries (#49)
* disable docker build for now * setup binary build workflow * add cross-rs config * fix job name * add justfile * remove unnecessary package * add job name * add job id * rename archive * reenable docker build --------- Co-authored-by: Maciej Wójcik <[email protected]>
1 parent 6aa824e commit 0726e53

File tree

3 files changed

+121
-4
lines changed

3 files changed

+121
-4
lines changed

.github/workflows/release.yml

+83-4
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,93 @@ jobs:
5050
cache-from: type=gha
5151
cache-to: type=gha,mode=max
5252

53-
release:
53+
create-release:
54+
name: create-release
5455
runs-on: self-hosted
56+
outputs:
57+
upload_url: ${{ steps.release.outputs.upload_url }}
5558
steps:
56-
- name: Checkout
57-
uses: actions/checkout@v3
58-
- name: Create release
59+
- name: Create GitHub release
60+
id: release
5961
uses: softprops/action-gh-release@v1
6062
if: startsWith(github.ref, 'refs/tags/')
6163
with:
6264
draft: true
6365
generate_release_notes: true
66+
67+
build-binaries:
68+
needs: [ "create-release" ]
69+
runs-on:
70+
- self-hosted
71+
- ${{ matrix.os }}
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
build: [ linux, linux-arm, linux-arm64, freebsd ]
76+
include:
77+
- build: linux
78+
os: Linux
79+
target: x86_64-unknown-linux-gnu
80+
- build: linux-arm
81+
os: Linux
82+
target: armv7-unknown-linux-gnueabihf
83+
- build: linux-arm64
84+
os: Linux
85+
target: aarch64-unknown-linux-gnu
86+
- build: freebsd
87+
os: Linux
88+
target: x86_64-unknown-freebsd
89+
steps:
90+
# Store the version, stripping any v-prefix
91+
- name: Write release version
92+
run: |
93+
VERSION=${GITHUB_REF_NAME#v}
94+
echo Version: $VERSION
95+
echo "VERSION=$VERSION" >> $GITHUB_ENV
96+
97+
- name: Checkout
98+
uses: actions/checkout@v3
99+
with:
100+
submodules: recursive
101+
102+
- name: Install Rust stable
103+
uses: actions-rs/toolchain@v1
104+
with:
105+
toolchain: stable
106+
target: ${{ matrix.target }}
107+
override: true
108+
109+
- name: Set up Docker BuildX
110+
uses: docker/setup-buildx-action@v3
111+
with:
112+
config-inline: |
113+
[registry."docker.io"]
114+
mirrors = ["dockerhub-proxy.teonite.net"]
115+
116+
- name: Build release binary
117+
uses: actions-rs/cargo@v1
118+
with:
119+
use-cross: true
120+
command: build
121+
args: --locked --release --target ${{ matrix.target }}
122+
123+
- name: Rename binary
124+
run: mv target/${{ matrix.target }}/release/defguard-proxy defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}
125+
126+
- name: Tar
127+
uses: a7ul/[email protected]
128+
with:
129+
command: c
130+
files: |
131+
defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}
132+
outPath: defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
133+
134+
- name: Upload release archive
135+
uses: actions/[email protected]
136+
env:
137+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138+
with:
139+
upload_url: ${{ needs.create-release.outputs.upload_url }}
140+
asset_path: defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
141+
asset_name: defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
142+
asset_content_type: application/octet-stream

Cross.toml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[target.x86_64-unknown-linux-gnu]
2+
pre-build = ["apt-get update && apt-get install --assume-yes unzip ",
3+
"PB_REL='https://github.com/protocolbuffers/protobuf/releases'",
4+
"PB_VERSION='3.20.0' && curl -LO $PB_REL/download/v$PB_VERSION/protoc-$PB_VERSION-linux-x86_64.zip",
5+
"unzip protoc-$PB_VERSION-linux-x86_64.zip bin/protoc include/google/* -d /usr"]
6+
7+
[target.armv7-unknown-linux-gnueabihf]
8+
pre-build = ["apt-get update && apt-get install --assume-yes unzip ",
9+
"PB_REL='https://github.com/protocolbuffers/protobuf/releases'",
10+
"PB_VERSION='3.20.0' && curl -LO $PB_REL/download/v$PB_VERSION/protoc-$PB_VERSION-linux-x86_64.zip",
11+
"unzip protoc-$PB_VERSION-linux-x86_64.zip bin/protoc include/google/* -d /usr"]
12+
13+
[target.aarch64-unknown-linux-gnu]
14+
pre-build = ["apt-get update && apt-get install --assume-yes unzip ",
15+
"PB_REL='https://github.com/protocolbuffers/protobuf/releases'",
16+
"PB_VERSION='3.20.0' && curl -LO $PB_REL/download/v$PB_VERSION/protoc-$PB_VERSION-linux-x86_64.zip",
17+
"unzip protoc-$PB_VERSION-linux-x86_64.zip bin/protoc include/google/* -d /usr"]
18+
19+
[target.x86_64-unknown-freebsd]
20+
pre-build = ["apt-get update && apt-get install --assume-yes unzip ",
21+
"PB_REL='https://github.com/protocolbuffers/protobuf/releases'",
22+
"PB_VERSION='3.20.0' && curl -LO $PB_REL/download/v$PB_VERSION/protoc-$PB_VERSION-linux-x86_64.zip",
23+
"unzip protoc-$PB_VERSION-linux-x86_64.zip bin/protoc include/google/* -d /usr"]

justfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# build release binary
2+
build:
3+
cargo build --release
4+
# move tag to current commit
5+
move-tag TAG:
6+
# remove local tag
7+
git tag --delete {{TAG}}
8+
# remove tag from remote
9+
git push --delete origin {{TAG}}
10+
# make new tag
11+
git tag {{TAG}}
12+
# push commits to remote
13+
git push
14+
# push new tag to remote
15+
git push origin {{TAG}}

0 commit comments

Comments
 (0)