-
Notifications
You must be signed in to change notification settings - Fork 14
105 lines (99 loc) · 3.72 KB
/
publish.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
name: Publish
on:
push:
tags:
- v*
workflow_dispatch:
inputs:
versionType:
description: 'Version Type'
required: true
default: 'alpha'
type: choice
options:
- alpha
- beta
- release
additionalVersionInfo:
description: 'Additional Version Info. Only relevant for beta versions.'
required: false
default: ''
type: string
permissions:
contents: read
jobs:
determine-environment:
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.get_environment.outputs.environment }}
version: ${{ steps.get_environment.outputs.version }}
tag: ${{ steps.get_environment.outputs.tag }}
steps:
- uses: actions/checkout@v3
- name: Determine Environment
id: get_environment
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
if [[ "${{ github.event.inputs.versionType }}" == 'alpha' ]]; then
echo "environment=Testing" >> $GITHUB_OUTPUT
echo "version=alpha" >> $GITHUB_OUTPUT
elif [[ "${{ github.event.inputs.versionType }}" == 'beta' ]]; then
echo "environment=Testing" >> $GITHUB_OUTPUT
echo "version=beta=${{ github.event.inputs.additionalVersionInfo }}" >> $GITHUB_OUTPUT
elif [[ "${{ github.event.inputs.versionType }}" == 'release' ]]; then
echo "environment=Release" >> $GITHUB_OUTPUT
echo "version=release" >> $GITHUB_OUTPUT
fi
echo "tag=false" >> $GITHUB_OUTPUT
elif [[ ${{ github.event.ref }} =~ refs\/tags\/v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-(0|[1-9]\d*)\.(0|[1-9]\d*) ]]; then
echo "environment=Release" >> $GITHUB_OUTPUT
echo "version=release" >> $GITHUB_OUTPUT
echo "tag=true" >> $GITHUB_OUTPUT
fi
determine-crowdin-branch:
runs-on: ubuntu-latest
outputs:
crowdin_branch: ${{ steps.get_crowdin_branch.outputs.crowdin_branch }}
steps:
- uses: actions/checkout@v4
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'
cache: 'gradle'
- name: Determine Crowdin branch
id: get_crowdin_branch
run: |
output=$(./gradlew crowdinBranch)
version=$(echo "$output" | grep -oP 'Crowdin branch: \K\d+\.x')
if [[ $version =~ ^[0-9]+\.x$ ]]; then
echo "Crowdin branch: $version"
echo "crowdin_branch=$version" >> $GITHUB_OUTPUT
else
echo "Invalid version: $version"
exit 1
fi
publish:
runs-on: ubuntu-latest
needs: [determine-crowdin-branch, determine-environment]
environment: ${{ needs.determine-environment.outputs.environment }}
if: needs.determine-environment.outputs.version != '' && needs.determine-environment.outputs.environment != ''
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'adopt'
cache: 'gradle'
- name: Install Crowdin CLI
run: npm i -g @crowdin/cli
- name: Download translations
run: crowdin download -b ${{ needs.determine-crowdin-branch.outputs.crowdin_branch }}
env:
CROWDIN_KEY: ${{ secrets.CROWDIN_KEY }}
- name: Publish
uses: gradle/gradle-build-action@v2.7.0
with:
arguments: publishAll -PMAVEN_URL=${{ secrets.MAVEN_URL }} -PMAVEN_USER=${{ secrets.MAVEN_USER }} -PMAVEN_TOKEN=${{ secrets.MAVEN_TOKEN }} -PCURSEFORGE_API=${{ secrets.CURSEFORGE_API }} -PMODRINTH_API=${{ secrets.MODRINTH_API }} -P${{ needs.determine-environment.outputs.version }}