-
Notifications
You must be signed in to change notification settings - Fork 680
124 lines (116 loc) · 4.52 KB
/
export_guide.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
name: 'Export Guide'
on:
# This will run the workflow every day at 01:00 UTC
# This will run against master and publish the development version of the guide
schedule:
- cron: '0 1 * * *'
# Allow running it manually against any ref
workflow_dispatch: { }
# Run on all push events
push: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Software OpenGL Rendering
run: sudo apt-get install xvfb libgl1-mesa-dri zopfli
- uses: actions/checkout@v3
- uses: ./.github/actions/gradle-setup
- name: Export Guide
run: DRI_PRIME=0 xvfb-run ./gradlew runGuideexport
- name: Optimize PNG compression
run: |
mkdir oxipng
curl -Ls https://github.com/shssoichiro/oxipng/releases/download/v8.0.0/oxipng-8.0.0-x86_64-unknown-linux-musl.tar.gz | tar --strip-components=1 -zx -C oxipng
find build/guide -name "*.png" -exec oxipng/oxipng --strip safe {} \;
- name: Recompress the guide json
run: |
gunzip build/guide/guide.*.json.gz
zopfli build/guide/guide.*.json
rm -f build/guide/guide.*.json
- uses: actions/upload-artifact@v3
with:
name: guide
path: build/guide/
# Attach the guide as a release artifact if we're building a tag which might be a release
attach-release-artifact:
if: startsWith(github.ref, 'refs/tags/fabric/v') || startsWith(github.ref, 'refs/tags/forge/v')
needs: build
name: Attach Release Artifact
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: guide
path: build/guide/
- name: Create ZIP
working-directory: build/guide
run: zip -r ../../guide-assets.zip .
- name: Release
uses: softprops/action-gh-release@v1
with:
files: guide-assets.zip
# This job publishes the release version of guides to S3
# Our general approach is that the latest release for any given
# Minecraft version will be used to upload the guide data for it.
# Since we build for both fabric/forge, we only upload tags
# starting with fabric/v[...]
publish-web-release:
needs: build
name: Publish Release to Web
runs-on: ubuntu-latest
environment: Production
if: startsWith(github.ref, 'refs/tags/fabric/v')
steps:
- uses: actions/download-artifact@v3
with:
name: guide
path: build/guide/
- id: versions
name: Determine Game and Mod-Version
run: |
GAME_VERSION=$(jq -r .gameVersion 'build/guide/index.json')
echo "Game-Version: $GAME_VERSION"
echo "GAME_VERSION=$GAME_VERSION" >> "$GITHUB_OUTPUT"
if [ -z "$GAME_VERSION" ]
then
exit 1
fi
- uses: jakejarvis/s3-sync-action@7ed8b112447abb09f1da74f3466e4194fc7a6311
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: 'guide-assets'
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
AWS_S3_ENDPOINT: 'https://02aa146d8ef70ae7f9548b98cbb63161.r2.cloudflarestorage.com'
AWS_REGION: 'auto'
SOURCE_DIR: 'build/guide/'
DEST_DIR: "minecraft-${{ steps.versions.outputs.GAME_VERSION }}"
# This job publishes to a development folder on the S3 bucket and only runs for
# the master branch. To avoid the cost of publishing the assets for every
# push to master, it'll only run for manually triggered workflows (workflow_dispatch)
# or once per night.
publish-web-snapshot:
needs: build
name: Publish Snapshot to Web
runs-on: ubuntu-latest
environment: Production
if: github.ref == 'refs/heads/master' && (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule')
steps:
- uses: actions/download-artifact@v3
with:
name: guide
path: build/guide/
# Finally, upload to S3
- uses: jakejarvis/s3-sync-action@7ed8b112447abb09f1da74f3466e4194fc7a6311
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: 'guide-assets'
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
AWS_S3_ENDPOINT: 'https://02aa146d8ef70ae7f9548b98cbb63161.r2.cloudflarestorage.com'
AWS_REGION: 'auto'
SOURCE_DIR: 'build/guide/'
DEST_DIR: "development"