Skip to content

Commit a0745db

Browse files
GitHub workflow
1 parent 4bcc777 commit a0745db

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

.github/workflows/release.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Build & Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
tags:
9+
- "v*"
10+
pull_request:
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
build:
18+
name: Build (${{ matrix.os }})
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os: [ubuntu-22.04, macos-14]
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Install dependencies (Ubuntu)
30+
if: runner.os == 'Linux'
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y --no-install-recommends \
34+
build-essential cmake ninja-build pkg-config libssl-dev
35+
36+
- name: Install dependencies (macOS)
37+
if: runner.os == 'macOS'
38+
run: |
39+
brew update
40+
brew install cmake ninja openssl@3 pkg-config
41+
42+
- name: Configure (Ubuntu)
43+
if: runner.os == 'Linux'
44+
run: |
45+
cmake -S easy-stun -B easy-stun/build -G Ninja -DCMAKE_BUILD_TYPE=Release
46+
47+
- name: Configure (macOS)
48+
if: runner.os == 'macOS'
49+
env:
50+
OPENSSL_ROOT_DIR: /opt/homebrew/opt/openssl@3
51+
PKG_CONFIG_PATH: /opt/homebrew/opt/openssl@3/lib/pkgconfig
52+
run: |
53+
cmake -S easy-stun -B easy-stun/build -G Ninja -DCMAKE_BUILD_TYPE=Release
54+
55+
- name: Build
56+
run: |
57+
cmake --build easy-stun/build
58+
59+
- name: Package artifact
60+
shell: bash
61+
run: |
62+
set -euo pipefail
63+
BIN="easy-stun/build/easy-stun"
64+
test -f "$BIN"
65+
66+
OS="${{ runner.os }}"
67+
ARCH="${{ runner.arch }}"
68+
OUTDIR="dist"
69+
mkdir -p "$OUTDIR"
70+
71+
NAME="easy-stun-${OS}-${ARCH}"
72+
cp "$BIN" "$OUTDIR/easy-stun"
73+
(cd "$OUTDIR" && tar -czf "${NAME}.tar.gz" easy-stun)
74+
75+
echo "ASSET_PATH=$OUTDIR/${NAME}.tar.gz" >> "$GITHUB_ENV"
76+
echo "ASSET_NAME=${NAME}.tar.gz" >> "$GITHUB_ENV"
77+
78+
- name: Upload build artifact (non-tag)
79+
if: startsWith(github.ref, 'refs/tags/') != true
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: easy-stun-${{ runner.os }}-${{ runner.arch }}
83+
path: ${{ env.ASSET_PATH }}
84+
if-no-files-found: error
85+
86+
- name: Upload release asset (tag)
87+
if: startsWith(github.ref, 'refs/tags/')
88+
uses: softprops/action-gh-release@v2
89+
with:
90+
files: ${{ env.ASSET_PATH }}
91+
generate_release_notes: true
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)