forked from dmdorman/hero6e-foundryvtt
-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (114 loc) · 5.1 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
name: Create Release
on:
push:
branches:
- main
jobs:
check_release:
runs-on: ubuntu-latest
if: github.repository == 'dmdorman/hero6e-foundryvtt'
outputs:
release: ${{ steps.extract_release.outputs.RELEASE }}
steps:
- uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get install jq
- name: Extract version number from system.json
id: extract_version
run: |
VERSION=$(jq -r .version system.json)
echo "System version: $VERSION"
echo "::set-output name=VERSION::$VERSION"
- name: Get the latest release
id: latest_release
run: |
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r .tag_name)
echo "Latest release: $LATEST_RELEASE"
echo "::set-output name=LATEST_RELEASE::$LATEST_RELEASE"
- name: Compare version and release
id: extract_release
run: |
if [[ "${{ steps.extract_version.outputs.VERSION }}" != "${{ steps.latest_release.outputs.LATEST_RELEASE }}" ]]; then
RELEASE="${{ steps.extract_version.outputs.VERSION }}"
echo "::set-output name=RELEASE::$RELEASE"
fi
prepare_release:
needs: check_release
if: (needs.check_release.outputs.release != '') && (github.repository == 'dmdorman/hero6e-foundryvtt')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: build css
run: npm ci && npm run compile
- name: validate formatting (via prettier) and perform static analysis (via eslint)
run: npm run validate
- name: Update release version in system.json
run: |
sed -i 's|"manifest": "[^"]*",|"manifest": "https://github.com/dmdorman/hero6e-foundryvtt/releases/download/${{ needs.check_release.outputs.release }}/system.json",|' system.json
sed -i 's|"download": "[^"]*",|"download": "https://github.com/dmdorman/hero6e-foundryvtt/releases/download/${{ needs.check_release.outputs.release }}/hero6efoundryvttv2.zip",|' system.json
- name: Make a FoundryVTT system package (manifest and stuff required for execution) and ignore the rest as it is already archived in GitHub and is only needed to build or develop
run: |
zip -r herofoundryvttv2.zip . -x .git/\* -x .github/\* -x node_modules/\* -x scss/\* -x .gitattributes -x .gitignore -x .git-blame-ignore-revs -x .eslintrc.json -x .npmignore -x .prettierignore -x .prettierrc.json -x gulpfile.mjs -x package.json -x package-lock.json
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: hero6efoundryvttv2.zip
path: hero6efoundryvttv2.zip
if-no-files-found: error
- name: Create and push tag
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag ${{ needs.check_release.outputs.release }}
git push origin ${{ needs.check_release.outputs.release }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.check_release.outputs.release }}
release_name: Release ${{ needs.check_release.outputs.release }}
draft: false
prerelease: false
- name: Upload system zip
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./hero6efoundryvttv2.zip
asset_name: hero6efoundryvttv2.zip
asset_content_type: application/zip
- name: Upload system.json
id: upload-system-json
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./system.json
asset_name: system.json
asset_content_type: application/json
- name: Set RELEASE_NAME environment variable
run: echo "RELEASE_NAME=${{ needs.check_release.outputs.release }}" >> $GITHUB_ENV
- name: Set MANIFEST_FILE_PATH environment variable
run: echo "MANIFEST_FILE_PATH=system.json" >> $GITHUB_ENV
outputs:
release_name: ${{ needs.check_release.outputs.release }}
manifest_file_path: system.json
publish_release:
needs: prepare_release
runs-on: ubuntu-latest
steps:
- name: Grab manifest file
run: wget https://github.com/${{ github.repository }}/releases/download/${{ needs.prepare_release.outputs.release_name }}/system.json
- name: Publish to Foundry
uses: Varriount/fvtt-autopublish@v2.0.1
with:
username: ${{ secrets.FOUNDRY_ADMIN_USERNAME }}
password: ${{ secrets.FOUNDRY_ADMIN_PASSWORD }}
module-id: ${{ secrets.FOUNDRY_ADMIN_MODULE_ID }}
manifest-url: https://github.com/${{ github.repository }}/releases/download/${{ needs.prepare_release.outputs.release_name }}/system.json
manifest-file: ${{ needs.prepare_release.outputs.manifest_file_path }}