Skip to content

Commit 161e482

Browse files
authored
Create build.yml
1 parent 50004ae commit 161e482

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

.github/workflows/build.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: WebViewPlugin Build
2+
3+
on:
4+
push:
5+
tags:
6+
- "[1-9].[0-9]+.[0-9]+"
7+
8+
env:
9+
# Path to the solution file relative to the root of the project.
10+
SOLUTION_FILE_PATH: ./QuickLook.Plugin.WebViewPlus.sln
11+
12+
# Configuration type to build.
13+
# You can convert this to a build matrix if you need coverage of multiple configuration types.
14+
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
15+
BUILD_CONFIGURATION: Release
16+
17+
#GITHUB_REF_NAME - short ref name of the branch or tag
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
build-webapp:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
with:
30+
repository: mooflu/WebViewPlus
31+
ref: master
32+
33+
- name: Detect package manager
34+
id: detect-package-manager
35+
run: |
36+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
37+
echo "manager=yarn" >> $GITHUB_OUTPUT
38+
echo "command=install" >> $GITHUB_OUTPUT
39+
echo "runner=yarn" >> $GITHUB_OUTPUT
40+
exit 0
41+
elif [ -f "${{ github.workspace }}/package.json" ]; then
42+
echo "manager=npm" >> $GITHUB_OUTPUT
43+
echo "command=ci" >> $GITHUB_OUTPUT
44+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
45+
exit 0
46+
else
47+
echo "Unable to determine package manager"
48+
exit 1
49+
fi
50+
51+
- name: Setup Node
52+
uses: actions/setup-node@v3
53+
with:
54+
node-version: "16"
55+
cache: ${{ steps.detect-package-manager.outputs.manager }}
56+
57+
- name: Install dependencies
58+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
59+
60+
- name: Build with vitejs
61+
run: ${{ steps.detect-package-manager.outputs.runner }} vite build
62+
63+
- name: Tar webapp files
64+
run: tar -C ./build -cvf webapp.tar .
65+
66+
- name: Upload artifact
67+
uses: actions/upload-artifact@v2
68+
with:
69+
name: webapp
70+
path: webapp.tar
71+
72+
build-plugin:
73+
needs: build-webapp
74+
75+
runs-on: windows-latest
76+
77+
steps:
78+
- uses: actions/checkout@v3
79+
with:
80+
ref: master
81+
submodules: recursive
82+
fetch-depth: 0
83+
84+
- uses: actions/download-artifact@v3
85+
with:
86+
name: webapp
87+
run: tar -C ./webApp -xvf webapp.tar
88+
89+
- name: Add MSBuild to PATH
90+
uses: microsoft/[email protected]
91+
92+
- name: Restore NuGet packages
93+
working-directory: ${{env.GITHUB_WORKSPACE}}
94+
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
95+
96+
- name: Build
97+
working-directory: ${{env.GITHUB_WORKSPACE}}
98+
# Add additional options to the MSBuild command line here (like platform or verbosity level).
99+
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
100+
run: msbuild /m /p:BuildInParallel=true /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}
101+
102+
# upload msi and zip artifacts so the publish job below can download and then update latest release via Linux
103+
- uses: actions/upload-artifact@v3
104+
with:
105+
name: quicklook-plugin
106+
path: QuickLook.Plugin.WebViewPlus.qlplugin
107+
108+
publish:
109+
needs: build-plugin
110+
111+
# one of the steps uses container action which is Linux only
112+
runs-on: ubuntu-latest
113+
114+
permissions: write-all
115+
116+
steps:
117+
- uses: actions/download-artifact@v3
118+
with:
119+
name: quicklook-plugin
120+
121+
- name: Publish release
122+
# see https://github.com/pyTooling/Actions/tree/main/releaser
123+
uses: pyTooling/Actions/releaser@main
124+
with:
125+
tag: ${{ env.GITHUB_REF_NAME }}
126+
rm: true
127+
token: ${{ secrets.GITHUB_TOKEN }}
128+
files: QuickLook.Plugin.WebViewPlus.qlplugin
129+

0 commit comments

Comments
 (0)