A game framework written with osu! in mind.
1# There is no manual way to call this out to run this on tags via UI.
2# See: https://github.community/t/workflow-dispatch-from-a-tag-in-actions-tab/130561
3on: workflow_dispatch
4name: Deploy - Framework
5
6jobs:
7 check-if-tag:
8 name: Set Package Version
9 runs-on: ubuntu-latest
10 outputs:
11 version: ${{steps.deployment.outputs.version}}
12 steps:
13 - name: Checkout
14 run: |
15 REPOSITORY="https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git"
16 BRANCH="${GITHUB_REF/#refs\/heads\//}"
17
18 git version
19 git clone --no-checkout ${REPOSITORY} .
20 git config --local gc.auto 0
21
22 git -c protocol.version=2 fetch --no-tags --prune --progress --depth=2 origin +${GITHUB_SHA}:refs/remotes/origin/${BRANCH}
23 git checkout --progress --force -B $BRANCH refs/remotes/origin/$BRANCH
24
25
26 - name: Set Variables
27 id: deployment
28 shell: bash
29 run: |
30 if [ $(git describe --exact-match --tags HEAD &> /dev/null; echo $?) == 0 ]; then
31 echo "::set-output name=VERSION::$(git describe --exact-match --tags HEAD)"
32 else
33 echo "fatal: no tag detected for HEAD. Workflow will now stop."
34 exit 128;
35 fi
36
37 pack-framework:
38 name: Pack (Framework)
39 runs-on: windows-latest
40 needs: [check-if-tag]
41 defaults:
42 run:
43 shell: powershell
44 steps:
45 - name: Checkout
46 uses: actions/checkout@v2
47
48 - name: Set Artifacts Directory
49 id: artifactsPath
50 run: echo "::set-output name=NUGET_ARTIFACTS::${{github.workspace}}\artifacts"
51
52 # FIXME: 3.1 LTS is required here because iOS builds refuse to build without it.
53 # https://itnext.io/how-to-support-multiple-net-sdks-in-github-actions-workflows-b988daa884e
54 - name: Install .NET 3.1.x LTS
55 uses: actions/setup-dotnet@v1
56 with:
57 dotnet-version: "3.1.x"
58
59 - name: Install .NET 5.0.x
60 uses: actions/setup-dotnet@v1
61 with:
62 dotnet-version: "5.0.x"
63
64 - name: Pack (Framework)
65 run: dotnet pack -c Release osu.Framework /p:Version=${{needs.check-if-tag.outputs.version}} /p:GenerateDocumentationFile=true -o ${{steps.artifactsPath.outputs.nuget_artifacts}}
66
67 - name: Upload Artifacts
68 uses: actions/upload-artifact@v2
69 with:
70 name: osu-framework
71 path: ${{steps.artifactsPath.outputs.nuget_artifacts}}\*.nupkg
72
73 pack-template:
74 name: Pack (Templates)
75 runs-on: windows-latest
76 needs: [check-if-tag]
77 defaults:
78 run:
79 shell: powershell
80 steps:
81 - name: Checkout
82 uses: actions/checkout@v2
83
84 - name: Set Artifacts Directory
85 id: artifactsPath
86 run: echo "::set-output name=NUGET_ARTIFACTS::${{github.workspace}}\artifacts"
87
88 - name: Install .NET 5.0.x
89 uses: actions/setup-dotnet@v1
90 with:
91 dotnet-version: "5.0.x"
92
93 - name: Pack (Template)
94 run: dotnet pack -c Release osu.Framework.Templates /p:Configuration=Release /p:Version=${{needs.check-if-tag.outputs.version}} /p:GenerateDocumentationFile=true /p:NoDefaultExcludes=true -o ${{steps.artifactsPath.outputs.nuget_artifacts}}
95
96 - name: Upload Artifacts
97 uses: actions/upload-artifact@v2
98 with:
99 name: osu-framework-templates
100 path: ${{steps.artifactsPath.outputs.nuget_artifacts}}\*.nupkg
101
102 pack-android:
103 name: Pack (Android)
104 runs-on: windows-latest
105 needs: [check-if-tag]
106 defaults:
107 run:
108 shell: powershell
109 steps:
110 - name: Checkout
111 uses: actions/checkout@v2
112
113 - name: Set Artifacts Directory
114 id: artifactsPath
115 run: echo "::set-output name=NUGET_ARTIFACTS::${{github.workspace}}\artifacts"
116
117 - name: Add msbuild to PATH
118 uses: microsoft/setup-msbuild@v1.0.2
119
120 - name: Pack (Android Framework)
121 run: msbuild -bl:msbuildlog.binlog -v:m -target:Pack -r osu.Framework.Android/osu.Framework.Android.csproj -p:Configuration=Release -p:Version=${{needs.check-if-tag.outputs.version}} -p:PackageOutputPath=${{steps.artifactsPath.outputs.nuget_artifacts}}
122
123 - name: Upload Artifacts
124 uses: actions/upload-artifact@v2
125 with:
126 name: osu-framework-android
127 path: ${{steps.artifactsPath.outputs.nuget_artifacts}}\*.nupkg
128
129 pack-ios:
130 name: Pack (iOS)
131 runs-on: macos-latest
132 needs: [check-if-tag]
133 defaults:
134 run:
135 shell: bash
136 steps:
137 - name: Checkout
138 uses: actions/checkout@v2
139
140 - name: Set Artifacts Directory
141 id: artifactsPath
142 run: echo "::set-output name=NUGET_ARTIFACTS::${{github.workspace}}/artifacts"
143
144 - name: Pack (iOS Framework)
145 run: msbuild -bl:msbuildlog.binlog -v:m -target:Pack -r osu.Framework.iOS/osu.Framework.iOS.csproj -p:Configuration=Release -p:Version=${{needs.check-if-tag.outputs.version}} -p:PackageOutputPath=${{steps.artifactsPath.outputs.nuget_artifacts}}
146
147 - name: Upload Artifacts
148 uses: actions/upload-artifact@v2
149 with:
150 name: osu-framework-ios
151 path: ${{steps.artifactsPath.outputs.nuget_artifacts}}/*.nupkg
152
153 release:
154 name: Release
155 runs-on: ubuntu-latest
156 needs: [check-if-tag, pack-android, pack-framework, pack-template, pack-ios]
157 steps:
158 - name: Create Artifact Directory
159 run: mkdir ${{github.workspace}}/artifacts/
160
161 - name: Download Artifacts
162 uses: actions/download-artifact@v2
163 with:
164 path: ${{github.workspace}}/artifacts/
165
166 # Artifacts create their own directories. Let's fix that!
167 # https://github.com/actions/download-artifact#download-all-artifacts
168 - name: Move Artifacts to root of subdirectory
169 working-directory: ${{github.workspace}}/artifacts/
170 run: |
171 mv -v **/*.nupkg $(pwd)
172 rm -rfv */
173
174 - name: Deploy
175 run: |
176 dotnet nuget add source https://api.nuget.org/v3/index.json -n authed-nuget -u ${{secrets.NUGET_USER_NAME}} -p ${{secrets.NUGET_AUTH_TOKEN}}
177 dotnet nuget push ${{github.workspace}}/artifacts/*.nupkg --skip-duplicate --source authed-nuget