-
Notifications
You must be signed in to change notification settings - Fork 17
200 lines (178 loc) · 9.13 KB
/
create_realease.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# creates a new release for LIVE and PTU channel every day at 4am when the corresponding global.ini
# was changed in the last 24 hours
#
# steps:
# 1. checkout the code
# 2. count the commits for the global.ini in the last 24 hours
# 3. get the current date
# - the following steps are only run then the commit count is > 0
# 4. create a release name with the correct version in it
# 5. create the zip
# 6. create the release
name: Create Releases
on:
workflow_dispatch: # used only to manually trigger the workflow from the GitHub website
inputs:
tag:
description: "Release Tag"
type: string
schedule:
- cron: "0 3 * * *"
jobs:
get_context_info:
name: Get Context Info
runs-on: ubuntu-latest
outputs:
DATE: ${{ steps.date.outputs.DATE }}
DATE_REV: ${{ steps.date_rev.outputs.DATE_REV }}
TIME: ${{ steps.time.outputs.TIME }}
NEW_COMMIT_COUNT_PTU: ${{ steps.new_commits_ptu.outputs.NEW_COMMIT_COUNT_PTU }}
NEW_COMMIT_COUNT_LIVE: ${{ steps.new_commits_live.outputs.NEW_COMMIT_COUNT_LIVE }}
COMMIT_PTU: ${{ steps.commit_ptu.outputs.COMMIT_PTU }}
COMMIT_LIVE: ${{ steps.commit_live.outputs.COMMIT_LIVE }}
RELEASE_TITLE_PTU: ${{ steps.title_ptu.outputs.RELEASE_TITLE_PTU }}
RELEASE_TITLE_LIVE: ${{ steps.title_live.outputs.RELEASE_TITLE_LIVE }}
LINK_PTU: ${{ steps.link_ptu.outputs.LINK_PTU }}
LINK_LIVE: ${{ steps.link_live.outputs.LINK_LIVE }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Timezone
id: timezone
run: sudo timedatectl set-timezone Europe/Berlin
- name: Get Date
id: date
run: echo "DATE=$(date '+%d.%m.%y')" >> $GITHUB_OUTPUT
- name: Get Date Reverse
id: date_rev
run: echo "DATE_REV=$(date '+%y.%m.%d')" >> $GITHUB_OUTPUT
- name: Get Time
id: time
run: echo "TIME=$(date '+%H:%M')" >> $GITHUB_OUTPUT
- name: Count New Commits On PTU # counts the commits to ptu/global.ini during the last 24 hours
id: new_commits_ptu
run: echo "NEW_COMMIT_COUNT_PTU=$(git log --oneline --since '24 hours ago' -- ptu/global.ini | wc -l)" >> $GITHUB_OUTPUT
- name: Count New Commits On LIVE # counts the commits to live/global.ini during the last 24 hours
id: new_commits_live
run: echo "NEW_COMMIT_COUNT_LIVE=$(git log --oneline --since '24 hours ago' -- live/global.ini | wc -l)" >> $GITHUB_OUTPUT
- name: Get Commit On PTU
id: commit_ptu
run: echo "COMMIT_PTU=$(git log --pretty=format:'%H' -n 1 --since '24 hours ago' -- ptu/global.ini)" >> $GITHUB_OUTPUT
- name: Get Commit On LIVE
id: commit_live
run: echo "COMMIT_LIVE=$(git log --pretty=format:'%H' -n 1 --since '24 hours ago' -- live/global.ini)" >> $GITHUB_OUTPUT
- name: Create Release Title For PTU
id: title_ptu # creates a title for the release that shows the version number used in the title of the last commit that changed the ptu/global.ini
if: steps.new_commits_ptu.outputs.NEW_COMMIT_COUNT_PTU > 0
# run: echo "RELEASE_TITLE_PTU=$(cat 'en/ptu/build.ptu')" >> $GITHUB_OUTPUT
run: |
if [$(git log -1 --pretty=%s -- ptu/global.ini | grep "|") == ""]
then
echo "RELEASE_TITLE_PTU=${{ vars.RELEASE_TITLE_PTU }}" >> $GITHUB_OUTPUT
else
echo "RELEASE_TITLE_PTU=$(git log -1 --pretty=%s -- ptu/global.ini | cut -s -d'|' -f1 | rev | cut -c 2- | rev) [de]" >> $GITHUB_OUTPUT
fi
- name: Create Release Title For LIVE
id: title_live # creates a title for the release that shows the version number used in the title of the last commit that changed the live/global.ini
if: steps.new_commits_live.outputs.NEW_COMMIT_COUNT_LIVE > 0
# run: echo "RELEASE_TITLE_LIVE=$(cat 'en/live/build.live')" >> $GITHUB_OUTPUT
run: |
if [$(git log -1 --pretty=%s -- live/global.ini | grep "|") == ""]
then
echo "RELEASE_TITLE_LIVE=${{ vars.RELEASE_TITLE_LIVE }}" >> $GITHUB_OUTPUT
else
echo "RELEASE_TITLE_LIVE=$(git log -1 --pretty=%s -- live/global.ini | cut -s -d'|' -f1 | rev | cut -c 2- | rev) [de]" >> $GITHUB_OUTPUT
fi
- name: Get Last Tag On PTU
id: tag_PTU
run: echo "TAG_PTU=$(git tag --sort=creatordate --list '*-PTU' | tail -1)" >> $GITHUB_OUTPUT
- name: Get Last Tag On LIVE
id: tag_live
run: echo "TAG_LIVE=$(git tag --sort=creatordate --list '*-LIVE' | tail -1)" >> $GITHUB_OUTPUT
- name: Create Compare Link For PTU
id: link_ptu
run: echo "LINK_PTU=https://github.com/${{ github.repository }}/compare/${{ steps.tag_PTU.outputs.TAG_PTU }}...${{ steps.date_rev.outputs.DATE_REV }}-PTU" >> $GITHUB_OUTPUT
- name: Create Compare Link For LIVE
id: link_live
run: echo "LINK_LIVE=https://github.com/${{ github.repository }}/compare/${{ steps.tag_live.outputs.TAG_LIVE }}...${{ steps.date_rev.outputs.DATE_REV }}-LIVE" >> $GITHUB_OUTPUT
- name: Show Variables
id: show_variable
run: |
echo "Date: ${{ steps.date.outputs.DATE }}"
echo "Date Reverse: ${{ steps.date_rev.outputs.DATE_REV }}"
echo "Time: ${{ steps.time.outputs.TIME }}"
echo "New Commits On PTU: ${{ steps.new_commits_ptu.outputs.NEW_COMMIT_COUNT_PTU }}"
echo "New Commits On LIVE: ${{ steps.new_commits_live.outputs.NEW_COMMIT_COUNT_LIVE }}"
echo "Commit On PTU: ${{ steps.commit_ptu.outputs.COMMIT_PTU }}"
echo "Commit On LIVE: ${{ steps.commit_live.outputs.COMMIT_LIVE }}"
echo "Release Title PTU: ${{ steps.title_ptu.outputs.RELEASE_TITLE_PTU }}"
echo "Release Title LIVE: ${{ steps.title_live.outputs.RELEASE_TITLE_LIVE }}"
echo "Last Tag on PTU: ${{ steps.tag_PTU.outputs.TAG_PTU }}"
echo "Last Tag on LIVE: ${{ steps.tag_live.outputs.TAG_LIVE }}"
echo "Changelog Link for PTU: ${{ steps.link_ptu.outputs.LINK_PTU }}"
echo "Changelog Link for LIVE: ${{ steps.link_live.outputs.LINK_LIVE }}"
ptu_release: # runs only when ptu/global.ini was changed in the last 24 hours
name: Create PTU Release
runs-on: ubuntu-latest
needs: get_context_info
if: (vars.TRIGGER_PTU_RELEASE == 1) && (needs.get_context_info.outputs.NEW_COMMIT_COUNT_PTU > 0)
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ needs.get_context_info.outputs.COMMIT_PTU }}
- name: Create ZIP For PTU
run: |
sudo timedatectl set-timezone Europe/Berlin
mkdir release
cp "ptu/user.cfg" "release"
mkdir -p "release/data/Localization/german_(germany)"
cp "ptu/global.ini" "release/data/Localization/german_(germany)/"
cd release
echo "${{ vars.VERSION_FILE_TEXT_PTU }} ${{ needs.get_context_info.outputs.RELEASE_TITLE_PTU }} ${{ needs.get_context_info.outputs.DATE }} - ${{ needs.get_context_info.outputs.TIME }} Uhr" >> Version.txt
zip -r -9 "../${{ vars.ZIP_NAME_PTU }}" *
- name: Create Release For PTU
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.WORKFLOW_TOKEN }}
tag: ${{ inputs.tag || needs.get_context_info.outputs.DATE_REV }}-PTU
commit: ${{ needs.get_context_info.outputs.COMMIT_PTU }}
name: ${{ needs.get_context_info.outputs.RELEASE_TITLE_PTU }}
body: ${{ vars.RELEASE_BODY_PTU }}(${{ needs.get_context_info.outputs.LINK_PTU }})
artifacts: ${{ vars.ZIP_NAME_PTU }}
live_release: # runs only when live/global.ini was changed in the last 24 hours
name: Create LIVE Release
runs-on: ubuntu-latest
needs: [get_context_info, ptu_release]
if: always() && (needs.get_context_info.outputs.NEW_COMMIT_COUNT_LIVE > 0)
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ needs.get_context_info.outputs.COMMIT_LIVE }}
- name: Create ZIP For LIVE
run: |
sudo timedatectl set-timezone Europe/Berlin
mkdir release
cp "live/user.cfg" "release"
mkdir -p "release/data/Localization/german_(germany)"
cp "live/global.ini" "release/data/Localization/german_(germany)/"
cd release
echo "${{ vars.VERSION_FILE_TEXT_LIVE }} ${{ needs.get_context_info.outputs.RELEASE_TITLE_LIVE }} ${{ needs.get_context_info.outputs.DATE }} - ${{ needs.get_context_info.outputs.TIME }} Uhr" >> Version.txt
zip -r -9 "../${{ vars.ZIP_NAME_LIVE }}" *
- name: Create Release For LIVE
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.WORKFLOW_TOKEN }}
tag: ${{ inputs.tag || needs.get_context_info.outputs.DATE_REV }}-LIVE
commit: ${{ needs.get_context_info.outputs.COMMIT_LIVE }}
name: ${{ needs.get_context_info.outputs.RELEASE_TITLE_LIVE }}
body: ${{ vars.RELEASE_BODY_LIVE }}(${{ needs.get_context_info.outputs.LINK_LIVE }})
artifacts: ${{ vars.ZIP_NAME_LIVE }}
makeLatest: true