Skip to content

Commit 950425c

Browse files
committed
Alright, AppVeyor is just worthless now, switch to github actions.
1 parent 0a1a405 commit 950425c

File tree

9 files changed

+239
-47
lines changed

9 files changed

+239
-47
lines changed

.github/workflows/main.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Build and Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
publish:
7+
description: 'Publish packages'
8+
type: boolean
9+
required: false
10+
default: false
11+
push:
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
env:
17+
CONFIGURATION: Release
18+
ISPUBLIC: 0
19+
LATEST: 0
20+
21+
steps:
22+
- if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
23+
run: echo "ISPUBLIC=1" >> $GITHUB_ENV
24+
25+
- if: ${{ github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/') }}
26+
run: echo "ISPUBLIC=1" >> $GITHUB_ENV
27+
28+
- if: ${{ github.ref == 'refs/heads/master' }}
29+
run: echo "LATEST=1" >> $GITHUB_ENV
30+
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
path: source
35+
- uses: actions/setup-dotnet@v4
36+
with:
37+
global-json-file: source/global.json
38+
39+
# - uses: dotnet/nbgv@master
40+
# with:
41+
# setAllVars: true
42+
# path: source
43+
44+
- name: dependencies
45+
working-directory: source
46+
run: |
47+
mkdir -p lib
48+
pushd lib
49+
curl -fSL --output deps.zip https://files.spoiledcat.com/deps.zip
50+
7z -y -bb3 x deps.zip
51+
popd
52+
- run: dotnet --list-sdks
53+
working-directory: source
54+
- run: node --version
55+
working-directory: source
56+
- run: npm --version
57+
working-directory: source
58+
59+
- run: for i in 1 2 3 4 5; do dotnet restore -v Minimal && break || sleep 1; done
60+
working-directory: source
61+
62+
- run: ./build.sh -c $CONFIGURATION --ispublic $ISPUBLIC --trace
63+
working-directory: source
64+
65+
- name: SpoiledBot
66+
id: token
67+
uses: getsentry/action-github-app-token@v2
68+
with:
69+
app_id: ${{ secrets.SPOILEDBOT_ID }}
70+
private_key: ${{ secrets.SPOILEDBOT_KEY }}
71+
72+
- uses: actions/checkout@v4
73+
with:
74+
fetch-depth: 0
75+
path: branches
76+
77+
# this lets us do commits and pushes without fiddling with keys
78+
- name: GH cli
79+
working-directory: branches
80+
run: |
81+
gh --version
82+
echo "${{ steps.token.outputs.token }}" | gh auth login --with-token
83+
gh auth status
84+
git config --global user.name "SpoiledBot"
85+
git config --global user.email "github@spoiledcat.net"
86+
87+
- run: ./publish.sh --ispublic $ISPUBLIC --branches --skip-clone --latest $LATEST
88+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.publish }}
89+
working-directory: source
90+
91+
- run: ./pack.sh -c $CONFIGURATION --ispublic $ISPUBLIC
92+
working-directory: source
93+
94+
- run: ./publish.sh --npm --ispublic $ISPUBLIC
95+
env:
96+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
97+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.publish }}
98+
working-directory: source
99+
100+
- uses: spoiledcat/upload-artifact@main
101+
with:
102+
path: 'source/build/**/*.nupkg'
103+
104+
- uses: spoiledcat/upload-artifact@main
105+
with:
106+
path: 'source/build/**/*.tgz'

build.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fi
1111
CONFIGURATION=Release
1212
PUBLIC=""
1313
UNITYBUILD=0
14+
CI=0
1415

1516
while (( "$#" )); do
1617
case "$1" in
@@ -36,6 +37,12 @@ while (( "$#" )); do
3637
PUBLIC="-p:PublicRelease=true"
3738
fi
3839
;;
40+
--ci)
41+
CI=1
42+
;;
43+
--trace)
44+
{ set -x; } 2>/dev/null
45+
;;
3946
-*|--*=) # unsupported flags
4047
echo "Error: Unsupported flag $1" >&2
4148
exit 1
@@ -44,13 +51,19 @@ while (( "$#" )); do
4451
shift
4552
done
4653

47-
if [[ x"$UNITYBUILD" == x"1" ]]; then
54+
if [[ x"${APPVEYOR:-}" != x"" ]]; then
55+
CI=1
56+
fi
57+
if [[ x"${GITHUB_REPOSITORY:-}" != x"" ]]; then
58+
CI=1
59+
fi
60+
if [[ x"${UNITYBUILD}" == x"1" ]]; then
4861
CONFIGURATION="${CONFIGURATION}Unity"
4962
fi
5063

5164
pushd $DIR >/dev/null 2>&1
5265

53-
if [[ x"${APPVEYOR:-}" == x"" ]]; then
66+
if [[ x"${CI}" == x"0" ]]; then
5467
dotnet restore
5568
fi
5669
dotnet build --no-restore -c $CONFIGURATION $PUBLIC

common/unityreferences.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<HubInstallDir Condition="!Exists('$(HubInstallDir)')"></HubInstallDir>
1717
<UnityDir Condition="$(UnityDir) == '' and Exists('$(RootDir)\script\lib\Managed\UnityEditor.dll')">$(RootDir)script\lib\</UnityDir>
1818
<UnityDir Condition="$(UnityDir) == '' and Exists('$(RootDir)\lib\Managed\UnityEditor.dll')">$(RootDir)lib\</UnityDir>
19+
<UnityDir Condition="$(UnityDir) == '' and Exists('$(RootDir)\.bin\Managed\UnityEditor.dll')">$(RootDir).bin\</UnityDir>
1920
<UnityDir Condition="$(UnityDir) == '' and Exists('\Applications\Unity\Unity.app\Contents\Managed\UnityEditor.dll')">\Applications\Unity\Unity.app\Contents\</UnityDir>
2021
<UnityDir Condition="$(UnityDir) == '' and Exists('C:\Program Files\Unity\Editor\Data\Managed\UnityEditor.dll')">C:\Program Files\Unity\Editor\Data\</UnityDir>
2122
<UnityDir Condition="$(UnityDir) == '' and Exists('C:\Program Files (x86)\Unity\Editor\Data\Managed\UnityEditor.dll')">C:\Program Files (x86)\Unity\Editor\Data\</UnityDir>

pack.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ BUILD=0
1414
UPM=0
1515
UNITYVERSION=2019.2
1616
UNITYBUILD=0
17+
ISPUBLIC=0
18+
CI=0
1719

1820
while (( "$#" )); do
1921
case "$1" in
@@ -43,8 +45,15 @@ while (( "$#" )); do
4345
shift
4446
if [[ x"$1" == x"1" ]]; then
4547
PUBLIC="-p:PublicRelease=true"
48+
ISPUBLIC=1
4649
fi
4750
;;
51+
--ci)
52+
CI=1
53+
;;
54+
--trace)
55+
{ set -x; } 2>/dev/null
56+
;;
4857
-*|--*=) # unsupported flags
4958
echo "Error: Unsupported flag $1" >&2
5059
exit 1
@@ -53,6 +62,12 @@ while (( "$#" )); do
5362
shift
5463
done
5564

65+
if [[ x"${APPVEYOR:-}" != x"" ]]; then
66+
CI=1
67+
fi
68+
if [[ x"${GITHUB_REPOSITORY:-}" != x"" ]]; then
69+
CI=1
70+
fi
5671
if [[ x"$UNITYBUILD" == x"1" ]]; then
5772
CONFIGURATION="${CONFIGURATION}Unity"
5873
fi
@@ -61,14 +76,16 @@ pushd $DIR >/dev/null 2>&1
6176

6277
if [[ x"$BUILD" == x"1" ]]; then
6378

64-
if [[ x"${APPVEYOR:-}" == x"" ]]; then
79+
if [[ x"${CI}" == x"0" ]]; then
6580
dotnet restore
6681
fi
6782
dotnet build --no-restore -c $CONFIGURATION $PUBLIC
6883

6984
fi
7085

86+
if [[ x"$ISPUBLIC" == x"1" ]]; then
7187
dotnet pack --no-build --no-restore -c $CONFIGURATION $PUBLIC
88+
fi
7289

7390
if [[ x"$UPM" == x"1" ]]; then
7491
powershell scripts/Pack-Upm.ps1

0 commit comments

Comments
 (0)