Skip to content

Commit 15f9c5b

Browse files
authored
Refactor GitHub Actions workflow for building project
1 parent eba152d commit 15f9c5b

File tree

1 file changed

+12
-33
lines changed

1 file changed

+12
-33
lines changed

.github/workflows/myaction.yml

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,21 @@
1-
name: release-hello-world
1+
name: build-hello-world
22

33
on:
4-
workflow_dispatch:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
58

69
jobs:
7-
create-release:
8-
permissions: write-all
10+
build-hello-world:
911
runs-on: ubuntu-latest
1012
steps:
1113
- uses: actions/checkout@v4
12-
- name: Create Release
13-
env:
14-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15-
run: gh release create ${{ github.ref_name }} --generate-notes --title "Version ${{ github.ref_name }}"
16-
17-
build-hello-world:
18-
needs: create-release
19-
permissions: write-all
20-
21-
strategy:
22-
matrix:
23-
include:
24-
- os: ubuntu-latest
25-
file_name: hello_world_linux
26-
- os: macos-latest
27-
file_name: hello_world_mac
28-
- os: windows-latest
29-
file_name: hello_world_windows.exe
3014

31-
runs-on: ${{ matrix.os }}
32-
name: ${{ matrix.os }}
33-
34-
steps:
35-
- uses: actions/checkout@v4
36-
- name: compile
37-
run: g++ hello_world.cpp -o ${{ matrix.file_name }}
15+
- name: install g++
16+
run: sudo apt install -y g++
3817

39-
- name: Update Release
40-
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
run: gh release upload ${{ github.ref_name }} "${{ matrix.file_name}}"
18+
- name: check build
19+
run: |
20+
g++ hello_world.cpp -o hello_world
21+
./hello_world

0 commit comments

Comments
 (0)