generated from vrchat-community/template-package
-
Notifications
You must be signed in to change notification settings - Fork 23
152 lines (133 loc) · 5.05 KB
/
build-release.yml
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
name: Build Release
on:
workflow_dispatch:
push:
branches:
- main
tags:
- '**'
env:
packageName: "nadena.dev.ndmf"
jobs:
run-tests:
needs: [prechecks]
if: needs.prechecks.outputs.need-new-tag == 'true'
uses: bdunderscore/ndmf/.github/workflows/gameci.yml@main
permissions:
checks: write
contents: read
secrets: inherit
prechecks:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
need-new-tag: ${{ steps.check-tag.outputs.need-new-tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: get version
id: version
run: |
sudo apt-get -y install jq
version=$(jq -r .version package.json)
if [ x$version == x ]; then
echo "Unable to extract version"
exit 1
fi
echo version=$(jq -r .version package.json) >> $GITHUB_OUTPUT
echo current_version=$(jq -r .version package.json) >> $GITHUB_ENV
- name: Check if version is tagged
id: check-tag
run: |
if git fetch origin $current_version --depth=1; then
echo "Version $current_version is already tagged"
echo "need-new-tag=false" >> $GITHUB_OUTPUT
else
echo "Version $current_version is not tagged"
echo "need-new-tag=true" >> $GITHUB_OUTPUT
fi
- name: Verify that this is the first revision with this version
if: steps.check-tag.outputs.need-new-tag == 'true'
run: |
git fetch --unshallow
git checkout HEAD~ package.json
if [ "$(jq -r .version package.json)" == "$current_version" ]; then
echo "Error: Looks like we skipped the version bump commit."
exit 1
fi
- name: Check semver syntax
if: steps.check-tag.outputs.need-new-tag == 'true'
id: semver-check
run: |
chmod +x .github/workflows/*.sh
.github/workflows/check-semver-syntax.sh ${{ steps.version.outputs.version }}
- name: Check tag consistency
if: startsWith(github.ref, 'refs/tags/')
run: |
if [ "${{ steps.version.outputs.version }}" != "${GITHUB_REF##*/}" ]; then
echo "Version in package.json does not match tag name: ${{ steps.version.outputs.version }} != ${GITHUB_REF##*/}"
exit 1
fi
create-release:
needs: [prechecks, run-tests]
runs-on: ubuntu-latest
if: needs.prechecks.outputs.need-new-tag == 'true' || startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Reexport version
id: version
run: |
echo "version=${{ needs.prechecks.outputs.version }}" >> $GITHUB_ENV
if [ "x${{ needs.prechecks.outputs.version }}" == "x" ]; then
echo "Unable to extract version"
exit 1
fi
# Re-check semver syntax in case this is being triggered by a manual tag push
- name: Check semver syntax
if: steps.check_tagged.outputs.need_tag == 'true'
id: semver-check
run: |
chmod +x .github/workflows/*.sh
.github/workflows/check-semver-syntax.sh ${{ needs.prechecks.outputs.version }}
- name: Check tag consistency
if: startsWith(github.ref, 'refs/tags/')
run: |
if [ "${{ needs.prechecks.outputs.version }}" != "${GITHUB_REF##*/}" ]; then
echo "Version in package.json does not match tag name: ${{ needs.prechecks.outputs.version }} != ${GITHUB_REF##*/}"
exit 1
fi
- name: Set Environment Variables
run: |
echo "zipFile=${{ env.packageName }}-${{ needs.prechecks.outputs.version }}".zip >> $GITHUB_ENV
echo "unityPackage=${{ env.packageName }}-${{ needs.prechecks.outputs.version }}.unitypackage" >> $GITHUB_ENV
- name: Create Zip
run: |
zip ".github/${{env.zipFile}}" ./* -r -x .github .git '.git/*' '*~/*' '*.ps1*'
- name: Move zipfile
run: |
mv .github/${{env.zipFile}} ${{env.zipFile}}
- uses: actions/upload-artifact@v4
with:
name: package-zip
path: ${{ env.zipFile }}
- name: Create tag
if: needs.prechecks.outputs.need-new-tag == 'true'
run: |
git config user.name "Github Actions"
git config user.email "[email protected]"
git tag ${{ needs.prechecks.outputs.version }}
git push origin ${{ needs.prechecks.outputs.version }}
- name: Make Release
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974
if: needs.prechecks.outputs.need-new-tag == 'true' || startsWith(github.ref, 'refs/tags/')
with:
draft: true
generate_release_notes: true
tag_name: ${{ needs.prechecks.outputs.version }}
name: ${{ needs.prechecks.outputs.version }}
files: |
${{ env.zipFile }}
package.json