Skip to content

Commit

Permalink
Update create_realease.yml | Workflow alle 14 Tage (#650)
Browse files Browse the repository at this point in the history
* Update create_realease.yml | Workflow alle 14 Tage

- Workflow alle 14 Tage
- Sofortiger Release bei Versionssprung. Beispiel 4.0.1 -> 4.0.2
- Titel zu beispielsweise `4.0.2 LIVE (Februar)`

* Update create_realease.yml

* Format

* Update release.yml

Revert changes from pyro
Release every 14days
Release on push when version changed
New Title

---------

Co-authored-by: MaxM1211 <maximaes12@gmail.com>
  • Loading branch information
rjcncpt and MaxM1211 authored Feb 22, 2025
1 parent 23ae540 commit 9efc6fc
Showing 1 changed file with 57 additions and 22 deletions.
79 changes: 57 additions & 22 deletions .github/workflows/create_realease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - 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
# 6. create the release

name: Create Releases
on:
Expand All @@ -17,8 +17,12 @@ on:
tag:
description: "Release Tag"
type: string
schedule:
- cron: "0 3 * * *"
schedule: # 3 am every 14 days
- cron: "0 3 */14 * *"
push:
branches:
- main

jobs:
get_context_info:
name: Get Context Info
Expand All @@ -27,6 +31,7 @@ jobs:
DATE: ${{ steps.date.outputs.DATE }}
DATE_REV: ${{ steps.date_rev.outputs.DATE_REV }}
TIME: ${{ steps.time.outputs.TIME }}
MONTH: ${{ steps.month.outputs.MONTH }}
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 }}
Expand All @@ -35,6 +40,8 @@ jobs:
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 }}
VERSION_CHANGED_PTU: ${{ steps.version_jump_ptu.outputs.VERSION_CHANGED_PTU }}
VERSION_CHANGED_LIVE: ${{ steps.version_jump_live.outputs.VERSION_CHANGED_LIVE }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
Expand All @@ -43,7 +50,10 @@ jobs:

- name: Set Timezone
id: timezone
run: sudo timedatectl set-timezone Europe/Berlin
run: |
sudo timedatectl set-timezone Europe/Berlin
sudo apt install -y locales
sudo locale-gen de_DE.UTF-8
- name: Get Date
id: date
Expand All @@ -57,44 +67,44 @@ jobs:
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
- name: Get Month
id: month
run: echo "MONTH=$(LC_ALL="de_DE.UTF-8" date '+%B')" >> $GITHUB_OUTPUT

- name: Count New Commits On PTU # counts the commits to ptu/global.ini during the last 14 days
id: new_commits_ptu
run: echo "NEW_COMMIT_COUNT_PTU=$(git log --oneline --since '24 hours ago' -- ptu/global.ini | wc -l)" >> $GITHUB_OUTPUT
run: echo "NEW_COMMIT_COUNT_PTU=$(git log --oneline --since '14 days 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
- name: Count New Commits On LIVE # counts the commits to live/global.ini during the last 14 days
id: new_commits_live
run: echo "NEW_COMMIT_COUNT_LIVE=$(git log --oneline --since '24 hours ago' -- live/global.ini | wc -l)" >> $GITHUB_OUTPUT
run: echo "NEW_COMMIT_COUNT_LIVE=$(git log --oneline --since '14 days 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
run: echo "COMMIT_PTU=$(git log --pretty=format:'%H' -n 1 --since '14 days 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

run: echo "COMMIT_LIVE=$(git log --pretty=format:'%H' -n 1 --since '14 days 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 '.github/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
echo "RELEASE_TITLE_PTU=${{ vars.RELEASE_TITLE_PTU }} (${{ steps.month.outputs.MONTH }})" >> $GITHUB_OUTPUT
else
echo "RELEASE_TITLE_PTU=$(git log -1 --pretty=%s -- ptu/global.ini | cut -s -d'|' -f1 | rev | cut -c 2- | rev)" >> $GITHUB_OUTPUT
echo "RELEASE_TITLE_PTU=$(git log -1 --pretty=%s -- ptu/global.ini | cut -s -d'|' -f1 | rev | cut -c 2- | rev | cut -s -d' ' -f1) PTU (${{ steps.month.outputs.MONTH }})" >> $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 '.github/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
echo "RELEASE_TITLE_LIVE=${{ vars.RELEASE_TITLE_LIVE }} (${{ steps.month.outputs.MONTH }})" >> $GITHUB_OUTPUT
else
echo "RELEASE_TITLE_LIVE=$(git log -1 --pretty=%s -- live/global.ini | cut -s -d'|' -f1 | rev | cut -c 2- | rev)" >> $GITHUB_OUTPUT
echo "RELEASE_TITLE_LIVE=$(git log -1 --pretty=%s -- live/global.ini | cut -s -d'|' -f1 | rev | cut -c 2- | rev | cut -s -d' ' -f1) LIVE (${{ steps.month.outputs.MONTH }})" >> $GITHUB_OUTPUT
fi
- name: Get Last Tag On PTU
Expand All @@ -113,12 +123,35 @@ jobs:
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: Version Jump PTU
id: version_jump_ptu
run: |
PREV_VERSION=$(git log -2 --pretty=%s -- ptu/global.ini | tail -1 | cut -s -d'|' -f1 | rev | cut -c 2- | rev | cut -s -d' ' -f1)
CURR_VERSION=$(git log -1 --pretty=%s -- ptu/global.ini | cut -s -d'|' -f1 | rev | cut -c 2- | rev | cut -s -d' ' -f1)
if [ "$PREV_VERSION" != "$CURR_VERSION" ]; then
echo "VERSION_CHANGED_PTU=true" >> $GITHUB_OUTPUT
else
echo "VERSION_CHANGED_PTU=false" >> $GITHUB_OUTPUT
fi
- name: Version Jump LIVE
id: version_jump_live
run: |
PREV_VERSION=$(git log -2 --pretty=%s -- live/global.ini | tail -1 | cut -s -d'|' -f1 | rev | cut -c 2- | rev | cut -s -d' ' -f1)
CURR_VERSION=$(git log -1 --pretty=%s -- live/global.ini | cut -s -d'|' -f1 | rev | cut -c 2- | rev | cut -s -d' ' -f1)
if [ "$PREV_VERSION" != "$CURR_VERSION" ]; then
echo "VERSION_CHANGED_LIVE=true" >> $GITHUB_OUTPUT
else
echo "VERSION_CHANGED_LIVE=false" >> $GITHUB_OUTPUT
fi
- 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 "Month: ${{ steps.month.outputs.MONTH }}"
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 }}"
Expand All @@ -129,12 +162,14 @@ jobs:
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 }}"
echo "Version Jump PTU: ${{ steps.version_jump_ptu.outputs.VERSION_CHANGED_PTU }}"
echo "Version Jump LIVE: ${{ steps.version_jump_live.outputs.VERSION_CHANGED_LIVE }}"
ptu_release: # runs only when ptu/global.ini was changed in the last 24 hours
ptu_release: # runs only when ptu/global.ini was changed in the last 14 days or the version number was changed
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)
if: (vars.TRIGGER_PTU_RELEASE == 1) && (((github.event_name == 'schedule') && (needs.get_context_info.outputs.NEW_COMMIT_COUNT_PTU > 0)) || ((github.event_name == 'push') && (needs.get_context_info.outputs.VERSION_CHANGED_PTU == 'true')) || (github.event_name == 'workflow_dispatch'))
permissions:
contents: write
steps:
Expand Down Expand Up @@ -164,11 +199,11 @@ jobs:
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
live_release: # runs only when live/global.ini was changed in the last 14 days or the version number was changed
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)
if: always() && (((github.event_name == 'schedule') && (needs.get_context_info.outputs.NEW_COMMIT_COUNT_LIVE > 0)) || ((github.event_name == 'push') && (needs.get_context_info.outputs.VERSION_CHANGED_LIVE == 'true')) || (github.event_name == 'workflow_dispatch'))
permissions:
contents: write
steps:
Expand Down

0 comments on commit 9efc6fc

Please sign in to comment.