-
-
Notifications
You must be signed in to change notification settings - Fork 33
151 lines (126 loc) · 5.47 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
# SPDX-FileCopyrightText: 2022 Johannes Loher
#
# SPDX-License-Identifier: MIT
name: Release
on:
release:
types: [published]
env:
package_type: module
node_version: 16
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4.0.0
with:
node-version: ${{ env.node_version }}
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: .npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install dependencies
run: npm ci --cache .npm --prefer-offline
- name: Lint
run: npm run lint
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4.0.0
with:
node-version: ${{ env.node_version }}
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: .npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install dependencies
run: npm ci --cache .npm --prefer-offline
- name: Extract tag version number
id: get_version
uses: battila7/get-version-action@v2
- name: Substitute Manifest and Download Links For Versioned Ones
id: sub_manifest_link_version
uses: microsoft/variable-substitution@v1
with:
files: "src/${{ env.package_type }}.json"
env:
version: ${{ steps.get_version.outputs.version-without-v }}
url: https://github.com/${{ github.repository }}
manifest: https://github.com/${{ github.repository }}/releases/latest/download/${{ env.package_type }}.json
download: https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/${{ env.package_type }}.zip
- name: Build
run: npm run build
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
publish:
needs:
- lint
- build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download production artifacts for publication
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Create zip file
working-directory: ./dist
run: zip -r ../${{ env.package_type }}.zip .
- name: Create release
id: create_version_release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
name: ${{ github.event.release.name }}
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "./dist/${{ env.package_type }}.json, ./${{ env.package_type }}.zip"
tag: ${{ github.event.release.tag_name }}
body: ${{ github.event.release.body }}
- name: Get Module ID
id: moduleID
uses: notiz-dev/github-action-json-property@release
with:
path: "./dist/${{ env.package_type }}.json"
prop_path: "id"
- name: Get mininum
id: minimum
uses: notiz-dev/github-action-json-property@release
with:
path: "./dist/${{ env.package_type }}.json"
prop_path: "compatibility.minimum"
- name: Get verified
id: verified
uses: notiz-dev/github-action-json-property@release
with:
path: "./dist/${{ env.package_type }}.json"
prop_path: "compatibility.verified"
- name: Extract tag version number
id: get_version
uses: battila7/get-version-action@v2
- name: Foundry Release API
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.foundryvtt.com/_api/packages/release_version"
method: "POST"
customHeaders: '{"Content-Type": "application/json", "Authorization" : "${{ secrets.FOUNDRY_KEY }}"}'
data: '{"id": "${{ steps.moduleID.outputs.prop }}", "release": {"version": "${{ steps.get_version.outputs.version-without-v }}", "manifest": "https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/${{ env.package_type }}.json", "notes": "https://github.com/${{ github.repository }}/releases/tag/${{ github.event.release.tag_name }}/", "compatibility" : {"minimum": "${{ steps.minimum.outputs.prop }}", "verified": "${{ steps.verified.outputs.prop }}"}}}'
preventFailureOnNoResponse: true