Skip to content

Commit 0d92ad1

Browse files
committed
chore: seperate publish-build workflow
1 parent aa68179 commit 0d92ad1

2 files changed

Lines changed: 191 additions & 67 deletions

File tree

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
name: Build For Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
jobs:
8+
test:
9+
name: Test (Windows)
10+
runs-on: windows-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
config: [Release, Debug]
15+
arch: [x64, x86]
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
22+
- name: Download Foobar2000 SDK
23+
run: |
24+
curl -L https://www.foobar2000.org/files/SDK-2023-09-23.7z -o vendor/foobar2000_sdk.7z
25+
7z x vendor/foobar2000_sdk.7z -ovendor/sdk
26+
ls vendor/sdk
27+
28+
- name: Setup Msbuild
29+
uses: microsoft/setup-msbuild@v2
30+
31+
- name: Restore NuGet packages
32+
working-directory: ${{ github.workspace }}
33+
run: nuget restore foo_input_ncm.sln
34+
35+
- name: Build Test Executable
36+
working-directory: ${{ github.workspace }}
37+
run: |
38+
msbuild foo_input_ncm.sln -property:"Configuration=${{ matrix.config }};Platform=${{ matrix.arch}}" -target:foo_input_ncm_tests
39+
40+
- name: Run Tests (x86)
41+
working-directory: ${{ github.workspace }}/${{ matrix.config }}
42+
run: .\foo_input_ncm_tests.exe
43+
if: matrix.arch == 'x86'
44+
45+
- name: Run Tests (x64)
46+
working-directory: ${{ github.workspace }}/${{ matrix.arch }}/${{ matrix.config }}
47+
run: .\foo_input_ncm_tests.exe
48+
if: matrix.arch == 'x64'
49+
50+
matrix-build:
51+
name: Matrix Build
52+
runs-on: ${{ matrix.os }}
53+
needs: [test]
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
os: [windows-latest, macos-14]
58+
config: [Release]
59+
arch: [x64, x86]
60+
exclude:
61+
- os: macos-14
62+
arch: x86
63+
include:
64+
- os: windows-latest
65+
build-command: msbuild
66+
solution: foo_input_ncm.sln
67+
- os: macos-14
68+
build-command: xcodebuild
69+
workspace: foo_input_ncm.xcworkspace
70+
project: foo_input_ncm.xcodeproj
71+
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@v4
75+
with:
76+
submodules: recursive
77+
fetch-tags: true
78+
fetch-depth: 0
79+
80+
- name: Versioning
81+
run: |
82+
TAG=$(git describe --tags)
83+
VERSION=${TAG:1}
84+
echo "#define CURRENT_VERSION $VERSION" >> src/stdafx.h
85+
echo "----------------------------"
86+
cat src/stdafx.h
87+
shell: bash
88+
working-directory: ${{ github.workspace }}
89+
90+
- name: Download Foobar2000 SDK
91+
run: |
92+
curl -L https://www.foobar2000.org/files/SDK-2023-09-23.7z -o vendor/foobar2000_sdk.7z
93+
7z x vendor/foobar2000_sdk.7z -ovendor/sdk
94+
ls vendor/sdk
95+
96+
- name: (XCode) Switch XCode Version
97+
run: |
98+
sudo xcode-select --switch /Applications/Xcode_15.3.app
99+
xcodebuild -version
100+
if: matrix.os == 'macos-14'
101+
102+
- name: (XCode) List Scheme
103+
run: |
104+
xcodebuild -list -workspace ${{ matrix.workspace }}
105+
echo Build with scheme: foo_input_ncm-${{ matrix.config }}
106+
if: matrix.os == 'macos-14'
107+
108+
- name: (XCode) Build component bundle
109+
env:
110+
scheme: foo_input_ncm-${{ matrix.config }}
111+
run: |
112+
xcodebuild clean build -workspace ${{ matrix.workspace }} -scheme "$scheme" -configuration ${{ matrix.config }}
113+
if: matrix.os == 'macos-14'
114+
115+
- name: (MSBuild) Setup MSBuild
116+
uses: microsoft/setup-msbuild@v2
117+
if: matrix.os == 'windows-latest'
118+
119+
- name: (MSBuild) Restore NuGet packages
120+
working-directory: ${{ github.workspace }}
121+
run: nuget restore ${{ matrix.solution }}
122+
if: matrix.os == 'windows-latest'
123+
124+
- name: (MSBuild) Build component dll
125+
working-directory: ${{ github.workspace }}
126+
run: msbuild ${{ matrix.solution }} -property:"Configuration=${{ matrix.config }};Platform=${{ matrix.arch}}" -target:foo_input_ncm
127+
if: matrix.os == 'windows-latest'
128+
129+
- name: Upload Artifacts
130+
uses: actions/upload-artifact@v4
131+
with:
132+
name: dist-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.config }}
133+
path: ${{ github.workspace }}/dist
134+
if-no-files-found: error
135+
pack:
136+
name: Make fb2k-componet package
137+
runs-on: ubuntu-latest
138+
needs: matrix-build
139+
steps:
140+
- name: Download Artifacts (MacOS bundle)
141+
uses: actions/download-artifact@v4
142+
with:
143+
pattern: dist-macos-*-Release
144+
145+
- name: Download Artifacts (Windows dll)
146+
uses: actions/download-artifact@v4
147+
with:
148+
pattern: dist-windows-*-Release
149+
150+
- name: Touch Directories
151+
run: |
152+
mkdir -p win32/x64
153+
mkdir -p macos/mac
154+
working-directory: ${{ github.workspace }}
155+
156+
- name: Pack component - Windows
157+
run: |
158+
cp ${{ github.workspace }}/dist-windows-latest-x86-Release/foo_input_ncm.dll .
159+
cp -r ${{ github.workspace }}/dist-windows-latest-x64-Release/x64 .
160+
zip -r ${{ github.workspace }}/foo_input_ncm-win32.fb2k-component ./*
161+
working-directory: ${{ github.workspace }}/win32
162+
163+
- name: Pack component - MacOS
164+
run: |
165+
cp -r ${{ github.workspace }}/dist-macos-14-x64-Release/mac .
166+
zip -r ${{ github.workspace }}/foo_input_ncm-macos.fb2k-component ./*
167+
working-directory: ${{ github.workspace }}/macos
168+
169+
- name: Upload Artifacts
170+
uses: actions/upload-artifact@v4
171+
with:
172+
name: packages
173+
path: '${{ github.workspace }}/*.fb2k-component'
174+
175+
release:
176+
name: Publish Release
177+
runs-on: ubuntu-latest
178+
needs: pack
179+
if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
180+
steps:
181+
- name: Download Artifacts
182+
uses: actions/download-artifact@v4
183+
with:
184+
name: packages
185+
186+
- name: Upload to Release
187+
uses: softprops/action-gh-release@v2
188+
with:
189+
files: ${{ github.workspace }}/*.fb2k-component
190+
make_latest: true
191+
generate_release_notes: true

.github/workflows/build.yml

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Build All
33
on:
44
push:
55
branches: ['main', 'dev', 'dev/*']
6-
tags:
7-
- 'v*.*.*'
86

97
pull_request:
108
branches: ['main']
@@ -140,68 +138,3 @@ jobs:
140138
name: dist-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.config }}
141139
path: ${{ github.workspace }}/dist
142140
if-no-files-found: error
143-
pack:
144-
name: Make fb2k-componet package
145-
runs-on: ubuntu-latest
146-
needs: matrix-build
147-
steps:
148-
- name: Download Artifacts (MacOS bundle)
149-
uses: actions/download-artifact@v4
150-
with:
151-
pattern: dist-macos-*-Release
152-
153-
- name: Download Artifacts (Windows dll)
154-
uses: actions/download-artifact@v4
155-
with:
156-
pattern: dist-windows-*-Release
157-
158-
- name: Touch Directories
159-
run: |
160-
mkdir -p win32/x64
161-
mkdir -p macos/mac
162-
working-directory: ${{ github.workspace }}
163-
164-
- name: Pack component - Windows
165-
run: |
166-
cp ${{ github.workspace }}/dist-windows-latest-x86-Release/foo_input_ncm.dll .
167-
cp -r ${{ github.workspace }}/dist-windows-latest-x64-Release/x64 .
168-
zip -r ${{ github.workspace }}/foo_input_ncm-win32.fb2k-component ./*
169-
working-directory: ${{ github.workspace }}/win32
170-
171-
- name: Pack component - MacOS
172-
run: |
173-
cp -r ${{ github.workspace }}/dist-macos-14-x64-Release/mac .
174-
zip -r ${{ github.workspace }}/foo_input_ncm-macos.fb2k-component ./*
175-
working-directory: ${{ github.workspace }}/macos
176-
177-
- name: Upload Artifacts
178-
uses: actions/upload-artifact@v4
179-
with:
180-
name: packages
181-
path: '${{ github.workspace }}/*.fb2k-component'
182-
183-
release:
184-
name: Publish Release
185-
runs-on: ubuntu-latest
186-
needs: pack
187-
if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
188-
steps:
189-
- name: Download Artifacts
190-
uses: actions/download-artifact@v4
191-
with:
192-
name: packages
193-
- name: Determine Release type
194-
id: check
195-
run: |
196-
if [[ "${{ github.ref }}" =~ ^refs/tags/v ]]; then
197-
echo "::set-output name=prerelease::false"
198-
else
199-
echo echo "::set-output name=prerelease::true"
200-
fi
201-
- name: Upload to Release
202-
uses: softprops/action-gh-release@v2
203-
with:
204-
files: ${{ github.workspace }}/*.fb2k-component
205-
make_latest: true
206-
generate_release_notes: true
207-
prerelease: ${{ steps.check.outputs.prerelease }}

0 commit comments

Comments
 (0)