Skip to content

Commit 83fd639

Browse files
committed
add release.yml
1 parent 0512ed5 commit 83fd639

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

.github/workflows/release.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Release Build
2+
3+
on:
4+
push:
5+
tags: ["*"]
6+
7+
env:
8+
EXECUTABLE_NAME: "qubic-cli"
9+
10+
jobs:
11+
build-and-release:
12+
runs-on: ${{ matrix.os }}
13+
permissions:
14+
contents: write # Required to create releases
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ubuntu-latest, windows-latest]
20+
build_type: [Release]
21+
cpp_compiler: [g++, clang++, cl]
22+
include:
23+
- os: windows-latest
24+
cpp_compiler: cl
25+
- os: ubuntu-latest
26+
cpp_compiler: g++
27+
- os: ubuntu-latest
28+
cpp_compiler: clang++
29+
exclude:
30+
- os: windows-latest
31+
cpp_compiler: g++
32+
- os: windows-latest
33+
cpp_compiler: clang++
34+
- os: ubuntu-latest
35+
cpp_compiler: cl
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Set reusable strings
41+
id: strings
42+
shell: bash
43+
run: |
44+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
45+
46+
- name: Configure CMake
47+
run: >
48+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
49+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
50+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
51+
-S ${{ github.workspace }}
52+
53+
- name: Build
54+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
55+
56+
# Locate the binary file
57+
- name: Locate Binary
58+
id: locate-binary
59+
shell: bash
60+
run: |
61+
if [[ "${{ runner.os }}" == "Windows" ]]; then
62+
echo "binary_path=${{ steps.strings.outputs.build-output-dir }}/Release/${{ env.EXECUTABLE_NAME }}.exe" >> $GITHUB_OUTPUT
63+
else
64+
echo "binary_path=${{ steps.strings.outputs.build-output-dir }}/${{ env.EXECUTABLE_NAME }}" >> $GITHUB_OUTPUT
65+
fi
66+
67+
# Create/Update Release and Upload Binary
68+
- name: Upload to Release
69+
uses: softprops/action-gh-release@v2
70+
if: startsWith(github.ref, 'refs/tags/')
71+
with:
72+
# This will append the binary from the current matrix job to the release
73+
files: ${{ steps.locate-binary.outputs.binary_path }}
74+
# This is where your disclaimer goes:
75+
body: |
76+
## Automated Build
77+
**Precaution:** These binaries are compiled by github workflow. It's recommended that you should download the source code and compile it yourself.
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)