Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Commit f6ad206

Browse files
committed
ci(C): auto build and release
1 parent 5e26d52 commit f6ad206

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

.github/workflows/c.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: C
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
pull_request:
7+
branches: ["master"]
8+
9+
env:
10+
BUILD_TYPE: Release
11+
12+
jobs:
13+
build:
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
18+
runs-on: ${{ matrix.os }}
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: Configure CMake
24+
run: cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
25+
26+
- name: Build
27+
run: cmake --build ${{ github.workspace }}/build --config ${{ env.BUILD_TYPE }}
28+
29+
- name: Rename
30+
run: >
31+
mv
32+
${{ github.workspace }}/build/${{ matrix.os == 'windows-latest' && format('{0}/crack.exe', env.BUILD_TYPE) || 'crack' }}
33+
${{ github.workspace }}/build/${{ matrix.os }}-crack${{ matrix.os == 'windows-latest' && '.exe' || '' }}
34+
35+
- name: Upload artifact
36+
uses: actions/upload-artifact@v2
37+
with:
38+
name: ${{ matrix.os }}-artifact
39+
path: ${{ github.workspace }}/build/${{ matrix.os }}-crack${{ matrix.os == 'windows-latest' && '.exe' || '' }}
40+
41+
release:
42+
if: github.event_name == 'push'
43+
44+
needs: build
45+
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- uses: actions/checkout@v3
50+
51+
- name: Download artifact
52+
uses: actions/download-artifact@v2
53+
with:
54+
path: ${{ github.workspace }}/build
55+
56+
- name: Tag
57+
id: tag
58+
run: |
59+
tag=$(git log -n1 --format="%h")
60+
git config --local user.email "[email protected]"
61+
git config --local user.name "ProgramRipper"
62+
git tag -a $tag -m $tag
63+
git push --tags
64+
echo tag=$tag >> $GITHUB_OUTPUT
65+
66+
- name: Release
67+
uses: softprops/action-gh-release@v1
68+
with:
69+
tag_name: ${{ steps.tag.outputs.tag }}
70+
files: ${{ github.workspace }}/build/*-artifact/*

0 commit comments

Comments
 (0)