-
Notifications
You must be signed in to change notification settings - Fork 7
153 lines (132 loc) · 4.86 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Build Platform Target
on:
workflow_dispatch:
repository_dispatch:
types: ['build-ready']
push:
branches: ['main']
tags:
- '**'
env:
ITCH_IO_PUBLISH: 'true'
# Set ITCH_IO_API_KEY in Repository Secrets
jobs:
build:
runs-on: ubuntu-latest
outputs:
TAG_PUSH: ${{ steps.setenv.outputs.TAG_PUSH }}
PRERELEASE: ${{ steps.setenv.outputs.PRERELEASE }}
GIT_TAG: ${{ steps.setenv.outputs.GIT_TAG }}
ITCH_IO_PUBLISH: ${{ steps.setenv.outputs.ITCH_IO_PUBLISH }}
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: 'true'
- name: Set env
id: setenv
run: |
echo "Github Action Event: ${{ github.event_name }}"
# If HEAD commit contains tag, event is tag push or manual workflow dispatch rerun
if [ -n "$(git tag -l --contains HEAD)" ] && \
[ ${{ github.event_name }} != "repository_dispatch" ]; then \
echo "Tagged Release"; \
TAG_PUSH=true; \
PRERELEASE=false; \
else \
echo "Rolling Release"; \
TAG_PUSH=false; \
PRERELEASE=true; \
fi
GIT_TAG="$( git describe --tags --abbrev=0 )"
GIT_TAG=${GIT_TAG:=0.0.1}
echo "TAG_PUSH=${TAG_PUSH}" >> $GITHUB_OUTPUT
echo "PRERELEASE=${PRERELEASE}" >> $GITHUB_OUTPUT
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
echo "ITCH_IO_PUBLISH=${{ env.ITCH_IO_PUBLISH }}" >> $GITHUB_OUTPUT
- name: Fetch docker action
id: fetch-action
run: |
git clone https://github.com/V-Sekai/v-sekai-game.git
- name: Docker build project
id: docker
uses: ./v-sekai-game/docker/build-project
with:
repo: ${{ github.repository }}
nightly: ${{ steps.setenv.outputs.PRERELEASE }}
default_export: true
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: v-sekai-release
path: ${{ github.workspace }}/releases
- name: Set tag name
id: tag
run: |
TAG_NAME="$( echo "${{ steps.docker.outputs.VERSION_TAG }}" | cut -d '-' -f1 )"
# Rolling release tag
if [ ${{ steps.setenv.outputs.TAG_PUSH }} == "false" ]; then \
TAG_DATE="$( date +"%Y-%m-%d" )"; \
TAG_VERSION="$( echo "${{ steps.docker.outputs.VERSION_TAG }}" | cut -d '-' -f2- )"; \
TAG_NAME="${TAG_NAME}-nightly-${TAG_DATE}-${TAG_VERSION}"; \
fi
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_OUTPUT
release:
runs-on: ubuntu-latest
needs: build
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ needs.build.outputs.TAG_NAME }}
release_name: ${{ needs.build.outputs.TAG_NAME }} V-Sekai Model Explorer Release
draft: false
prerelease: ${{ needs.build.outputs.PRERELEASE }}
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: v-sekai-release
name: v-sekai-release
- name: Upload Release Asset
run: |
echo "Release Tag: ${{ needs.build.outputs.TAG_NAME }}."
cd v-sekai-release
echo "Uploading to ${{ steps.create_release.outputs.upload_url }}"
for file in *; do \
echo "Uploading $file..."; \
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.id }}/assets?name=${file}" \
-T "${file}"; \
done
itch-upload:
runs-on: ubuntu-latest
needs: [build]
# Publish only on v-sekai-game tag update
if: needs.build.outputs.ITCH_IO_PUBLISH == 'true' && needs.build.outputs.TAG_PUSH == 'true'
steps:
- name: Fetch docker itch action
id: fetch-itch-action
run: |
git clone https://github.com/V-Sekai/v-sekai-game.git
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/v-sekai-release
name: v-sekai-release
- name: Docker Itch.io Publish
uses: ./v-sekai-game/docker/itch-io
with:
api_key: ${{ secrets.ITCH_IO_API_KEY }}
filepath: v-sekai-release
itchio_project: projectname
release_version: ${{ needs.build.outputs.GIT_TAG }}