-
Notifications
You must be signed in to change notification settings - Fork 7
99 lines (96 loc) · 4.33 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
on:
push:
branches:
- main
schedule:
- cron: '0 0 1 * *'
jobs:
release:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Check if there have been changes to the wiki
id: wiki_confirm_no_changes
continue-on-error: true
run: |
if [ "$RUNNER_DEBUG" = "1" ]; then
exit 1
else
npm run wiki-check-changed $(git tag -l --sort=-v:refname)
fi
- name: Install zip
if: ${{ steps.wiki_confirm_no_changes.outcome == 'failure' }}
uses: montudor/action-zip@v1
- name: Scrape wiki
if: ${{ steps.wiki_confirm_no_changes.outcome == 'failure' }}
run: npm run scrape-wiki
- name: Format the output with StyLua
if: ${{ steps.wiki_confirm_no_changes.outcome == 'failure' }}
uses: JohnnyMorganz/stylua-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: output/
- name: Pack release
if: ${{ steps.wiki_confirm_no_changes.outcome == 'failure' }}
run: npm run pack-release
- name: Get release files and version
if: ${{ steps.wiki_confirm_no_changes.outcome == 'failure' }}
id: release_json
run: |
content=`cat ./dist/release/release.json`
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of optional handling for multi line json
echo "releaseJson=$content" >> $GITHUB_ENV
- name: Create release
if: ${{ steps.wiki_confirm_no_changes.outcome == 'failure' }}
id: create_release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ fromJson(env.releaseJson).version }}
tag: ${{ fromJson(env.releaseJson).tag }}
body: |
# 📅 ${{ fromJson(env.releaseJson).version }}
This release was automatically generated by [this GitHub Action Workflow](https://github.com/luttje/glua-api-snippets/blob/main/.github/workflows/release.yml).
## 📝 Attached Archives
With this release the following archives are attached:
- `*.lua.zip`: Annotations for Lua definitions to include in your workspace (e.g: for EmmyLua)
- `*.json.zip`: JSON definitions based on the Wiki contents (can be used for further processing)
## 📚 Lua Language Server Addon
With this release a new addon for [the Lua Language Server](https://github.com/LuaLS/lua-language-server) was made available in [the LLS-Addons repository](https://github.com/LuaLS/LLS-Addons).
The source of this release can be found in [the lua-language-server-addon branch](https://github.com/luttje/glua-api-snippets/tree/lua-language-server-addon).
artifacts: ${{ join(fromJson(env.releaseJson).releaseFiles, ',') }}
- name: Publish Lua Language Server Library
if: ${{ steps.wiki_confirm_no_changes.outcome == 'failure' }}
run: npm run publish-library
- name: Copy library to it's own branch
if: ${{ steps.wiki_confirm_no_changes.outcome == 'failure' }}
env:
LIBRARY_PATH: dist/libraries/garrysmod
TARGET_BRANCH: lua-language-server-addon
run: |
libraryPathFirstPart=`echo $LIBRARY_PATH | cut -d'/' -f1`
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
# git fetch
git checkout $TARGET_BRANCH 2>/dev/null || git checkout -b $TARGET_BRANCH
rm -rf $(ls -A | grep -vE ".git$|^$libraryPathFirstPart$")
mv $LIBRARY_PATH/* .
rm -rf $libraryPathFirstPart
git add -A
git diff-index --quiet HEAD || git commit -am "🚀 Update ${{ fromJson(env.releaseJson).version }}"
git push origin $TARGET_BRANCH # push to remote branch
# From here on the workflow repo no longer contains the dist files, nor node_modules (removed when publishing branch)