generated from tiddly-gittly/TiddlyWiki-TS-Plugin-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (86 loc) · 2.95 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
name: Release Plugins
on:
push:
tags:
- 'v*.*.*'
paths-ignore:
- 'README.md'
- 'docs/**'
- '.vscode'
pull_request:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
- '.vscode'
concurrency:
group: release-ci-group
cancel-in-progress: true
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
jobs:
Plugins:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- id: setPluginInfoJSON
run: |
content=`cat ./src/plugin.info`
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# here we replace "title": "$:/plugins/linonetwo/tw-example-plugin", to "title": "linonetwo/tw-example-plugin",
# so it can be used in tiddly-gittly/tw5-plugin-packer to find output path
content="${content//$\:\/plugins\//}"
# end of optional handling for multi line json
echo "::set-output name=pluginInfoJSON::$content"
- name: Get npm cache directory
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-node-
- name: Install dependencies
run: npm i
- name: Make Plugins
run: npm run make
env:
CI: true
CI_PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# this should be the same as `scripts/run-action.mjs`
- uses: tiddly-gittly/tw5-plugin-packer@v0.0.10
with:
minify: 'true'
# here we read plugin author and name from pluginInfoJSON, and pluginInfoJSON is read in the step above with id `setPluginInfoJSON`
source: 'dist/plugins/${{fromJson(steps.setPluginInfoJSON.outputs.pluginInfoJSON).title}}'
output: 'dist/out'
uglifyjs-options: '{ "warnings": false, "ie8": false, "safari10": false }'
cleancss-options: '{ "compatibility": "*", "level": 2 }'
- name: Make Demo Site
run: npx zx ./scripts/build-demo-html.mjs
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
dist/out/*.json
dist/out/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: ./dist/output
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1