forked from quisquous/cactbot
-
Notifications
You must be signed in to change notification settings - Fork 45
168 lines (144 loc) · 5.06 KB
/
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Create Release Artifact
on:
push:
branches:
- main
paths:
- 'package.json'
jobs:
validate_tag:
runs-on: ubuntu-latest
if: ${{ github.repository == 'OverlayPlugin/cactbot' }}
outputs:
version: ${{ steps.get_version.outputs.version }}
do_release: ${{ steps.check_tag.outputs.do_release }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Project Version
id: get_version
uses: 'euberdeveloper/ga-project-version@main'
- name: Check Tag Exists
id: check_tag
shell: bash
run: |
if [ "${{ steps.get_version.outputs.version }}" == "" ]; then
echo "Error: Unable to determine version from package.json"
exit 1
elif [ "$(git tag -l 'v${{ steps.get_version.outputs.version }}')" ]; then
echo "No version bump - ${{ steps.get_version.outputs.version }}."
echo "do_release=false" >> $GITHUB_OUTPUT
echo "Skipping remaining jobs."
else
echo "Version bump detected - ${{ steps.get_version.outputs.version }}"
echo "do_release=true" >> $GITHUB_OUTPUT
fi
validate_versions:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/setup-js-env
- name: Validate AssemblyInfo Versions
run: |
npm run validate-versions
create_release:
runs-on: windows-latest
needs: [validate_tag, validate_versions]
if: |
github.repository == 'OverlayPlugin/cactbot' &&
needs.validate_tag.outputs.do_release == 'true'
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up msbuild
uses: microsoft/[email protected]
- uses: ./.github/actions/setup-js-env
- name: Check dependencies cache
id: cache-dependencies
uses: actions/cache@v4
with:
path: ./plugin/ThirdParty
key: |
${{ runner.os }}-cactbot-${{ hashFiles('./util/fetch_deps.ts',
'./util/DEPS.json5') }}
restore-keys: |
${{ runner.os }}-cactbot-
- name: Fetch Dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |
npm run fetch-deps
shell: bash
- name: Build Cactbot Plugin
shell: cmd
run: |
msbuild /p:Configuration=Release /p:Platform=x64 plugin/Cactbot.sln
- name: Build JavaScript UI Module Bundles
run: |
npm run build
- name: Setup Staging Directory
run: |
./util/publish.sh
shell: bash
- name: Create Release Artifact
run: |
mkdir cactbot
mv publish/cactbot-release/cactbot/ cactbot
compress-archive cactbot cactbot-${{ needs.validate_tag.outputs.version }}.zip
shell: pwsh
- name: Create Tag
shell: bash
run: git tag "v${{ needs.validate_tag.outputs.version }}" && git push --tags
- name: Fetch Release Attributes
id: fetch_attributes
uses: zoexx/github-action-json-file-properties@release
with:
file_path: "package.json"
- name: Set Release Attributes
id: set_attributes
# Using pwsh, so output must be sent to $env:GITHUB_OUTPUT instead of $GITHUB_OUTPUT
shell: pwsh
run: |
$release_name = "${{ needs.validate_tag.outputs.version }}";
$release_draft = "false";
$release_summary = "${{steps.fetch_attributes.outputs.releaseSummary}}";
if ($release_summary) {
$release_name += ": " + $release_summary;
}
if ("${{steps.fetch_attributes.outputs.releaseInDraft}}" -eq "true") {
$release_draft = "true";
}
echo "Release Name: $release_name";
echo "Release as Draft: $release_draft";
echo "release_name=$release_name" >> $env:GITHUB_OUTPUT
echo "release_draft=$release_draft" >> $env:GITHUB_OUTPUT
- name: Create Release
uses: ncipollo/release-action@v1
with:
name: ${{ steps.set_attributes.outputs.release_name }}
tag: v${{ needs.validate_tag.outputs.version }}
artifacts: cactbot-${{ needs.validate_tag.outputs.version }}.zip
artifactContentType: application/zip
draft: ${{ steps.set_attributes.outputs.release_draft }}
generateReleaseNotes: true
create_npm_package:
needs: [create_release]
runs-on: ubuntu-latest
if: ${{ github.repository == 'OverlayPlugin/cactbot' }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- uses: ./.github/actions/setup-js-env
- run: node .github/scripts/npm-package.cjs
- run: npm publish
working-directory: npm-package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}