Skip to content

Commit 2e729fd

Browse files
authored
Merge pull request #1 from pqfif-oss/feat/action
feat: Add github action workflow to build and create draft release
2 parents 2730399 + 43156bd commit 2e729fd

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*" # v1.0.0, v2.1.3
7+
- "v*.*.*-*" # v1.0.0-alpha, v2.1.0-beta.1
8+
pull_request:
9+
branches: [main]
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
name: Build on ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
include:
19+
- os: ubuntu-latest
20+
target: linux-x64
21+
artifact_name: gw
22+
asset_name: pqc-gateway-linux-x64
23+
- os: macos-latest
24+
target: macos-arm64
25+
artifact_name: gw
26+
asset_name: pqc-gateway-macos-arm64
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
with:
32+
submodules: recursive
33+
34+
- name: Install dependencies (Ubuntu)
35+
if: matrix.os == 'ubuntu-latest'
36+
run: |
37+
sudo apt-get update
38+
sudo apt-get install -y build-essential cmake clang llvm-dev
39+
40+
- name: Install dependencies (macOS)
41+
if: startsWith(matrix.os, 'macos')
42+
run: |
43+
brew install cmake
44+
# Use Xcode clang instead of brew llvm for better compatibility
45+
sudo xcode-select --install || true
46+
echo "Using Xcode clang for ARM64 compatibility"
47+
48+
- name: Set up environment variables
49+
run: |
50+
if [ "${{ github.event_name }}" = "push" ] && [ "${{ startsWith(github.ref, 'refs/tags/') }}" = "true" ]; then
51+
echo "PGW_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
52+
else
53+
echo "PGW_VERSION=dev-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
54+
fi
55+
56+
- name: Initialize submodules
57+
run: |
58+
git submodule update --init --recursive
59+
60+
- name: Build project
61+
run: |
62+
make
63+
env:
64+
CC: clang
65+
CXX: clang++
66+
67+
- name: Verify build
68+
run: |
69+
./bin/gw -v
70+
file ./bin/gw
71+
72+
- name: Create tarball
73+
run: |
74+
mkdir -p dist
75+
cp bin/gw dist/
76+
cp README.md dist/
77+
cp LICENSE dist/
78+
tar -czf ${{ matrix.asset_name }}.tar.gz -C dist .
79+
80+
- name: Upload build artifacts
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: ${{ matrix.asset_name }}
84+
path: ${{ matrix.asset_name }}.tar.gz
85+
86+
release:
87+
name: Create Release
88+
needs: build
89+
runs-on: ubuntu-latest
90+
if: startsWith(github.ref, 'refs/tags/')
91+
92+
steps:
93+
- name: Checkout code
94+
uses: actions/checkout@v4
95+
96+
- name: Download all artifacts
97+
uses: actions/download-artifact@v4
98+
with:
99+
path: artifacts
100+
101+
- name: Display structure of downloaded files
102+
run: ls -la artifacts/
103+
104+
- name: Create Release
105+
id: create_release
106+
uses: actions/create-release@v1
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
with:
110+
tag_name: ${{ github.ref_name }}
111+
release_name: Release ${{ github.ref_name }}
112+
body: |
113+
## PQC Gateway Release ${{ github.ref_name }}
114+
115+
### Changes
116+
- Built from commit: ${{ github.sha }}
117+
- Automated build for multiple platforms
118+
119+
### Downloads
120+
- **Linux x64**: `pqc-gateway-linux-x64.tar.gz`
121+
- **macOS ARM64**: `pqc-gateway-macos-arm64.tar.gz`
122+
123+
### Installation
124+
1. Download the appropriate archive for your platform
125+
2. Extract: `tar -xzf pqc-gateway-<platform>.tar.gz`
126+
3. Make executable: `chmod +x gw`
127+
4. Run: `./gw -v` to verify installation
128+
129+
### Usage
130+
```bash
131+
# Start with config file
132+
./gw -c config.yaml
133+
134+
# Start configuration server
135+
./gw -s /path/to/config/dir
136+
137+
# Show help
138+
./gw -h
139+
```
140+
draft: true
141+
prerelease: false
142+
143+
- name: Upload Linux Release Asset
144+
uses: actions/upload-release-asset@v1
145+
env:
146+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147+
with:
148+
upload_url: ${{ steps.create_release.outputs.upload_url }}
149+
asset_path: artifacts/pqc-gateway-linux-x64/pqc-gateway-linux-x64.tar.gz
150+
asset_name: pqc-gateway-linux-x64.tar.gz
151+
asset_content_type: application/gzip
152+
153+
- name: Upload macOS ARM64 Release Asset
154+
uses: actions/upload-release-asset@v1
155+
env:
156+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+
with:
158+
upload_url: ${{ steps.create_release.outputs.upload_url }}
159+
asset_path: artifacts/pqc-gateway-macos-arm64/pqc-gateway-macos-arm64.tar.gz
160+
asset_name: pqc-gateway-macos-arm64.tar.gz
161+
asset_content_type: application/gzip

0 commit comments

Comments
 (0)