Skip to content

Commit 834a936

Browse files
Add GitHub Actions workflow for auto release
1 parent e03fd09 commit 834a936

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Auto Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
types: [closed]
10+
11+
jobs:
12+
create_release:
13+
if: github.event.pull_request.merged == true || github.event_name == 'push'
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Extract version from version.h
21+
id: version
22+
run: |
23+
ver=$(grep 'RELEASE_VERSION' lib/version.h | sed -E 's/.*"([^"]+)".*/\1/')
24+
echo "version=$ver" >> $GITHUB_OUTPUT
25+
26+
- name: Set release name
27+
id: rel_name
28+
run: |
29+
if [ "${{ github.event_name }}" = "pull_request" ]; then
30+
echo "release_name=${{ github.event.pull_request.title }}" >> $GITHUB_OUTPUT
31+
else
32+
echo "release_name=${{ github.event.head_commit.message }}" >> $GITHUB_OUTPUT
33+
fi
34+
35+
# ---------- BUILD SECTION ----------
36+
- name: Install dependencies
37+
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
38+
39+
- name: Build binary
40+
run: |
41+
gcc Flash-cli.c -o flash-linux-x64 -lcurl
42+
# -----------------------------------
43+
44+
- name: Create Release
45+
uses: softprops/action-gh-release@v2
46+
with:
47+
tag_name: ${{ steps.version.outputs.version }}
48+
name: ${{ steps.rel_name.outputs.release_name }}
49+
files: |
50+
flash-linux-x64
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)