From 5e7fb1a59c5f6dd774f013a3b5153438b327d4d9 Mon Sep 17 00:00:00 2001 From: MaxM1211 Date: Thu, 7 Dec 2023 20:00:42 +0100 Subject: [PATCH] Update create_realease.yml --- .github/workflows/create_realease.yml | 113 +++++++++++++++++++------- 1 file changed, 82 insertions(+), 31 deletions(-) diff --git a/.github/workflows/create_realease.yml b/.github/workflows/create_realease.yml index f0138ac0..6a708198 100644 --- a/.github/workflows/create_realease.yml +++ b/.github/workflows/create_realease.yml @@ -4,12 +4,21 @@ # steps: # 1. checkout the code # 2. count the commits for the global.ini in the last 24 hours -# - the following steps are only run then the commit count is > 0 # 3. get the current date -# 4. create the zip -# 5. create the release +# - 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 on: + workflow_dispatch: # used only for testing to trigger the workflow from the GitHub website + inputs: + logLevel: + description: 'Log Level' + required: true + default: 'warning' + tags: + description: 'Test Scenario Tags' schedule: - cron: "0 3 * * *" @@ -19,38 +28,83 @@ jobs: get_context_info: runs-on: ubuntu-latest outputs: - DATE: ${{steps.date.outputs.date}} NEW_COMMIT_COUNT_LIVE: ${{steps.new_commits_live.outputs.NEW_COMMIT_COUNT_LIVE}} NEW_COMMIT_COUNT_PTU: ${{steps.new_commits_ptu.outputs.NEW_COMMIT_COUNT_PTU}} + DATE: ${{steps.date.outputs.DATE}} + RELEASE_TITLE_LIVE: ${{steps.title_live.outputs.RELEASE_TITLE_LIVE}} + RELEASE_TITLE_PTU: ${{steps.title_ptu.outputs.RELEASE_TITLE_PTU}} steps: - - name: Checkout code + - name: Checkout Code uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Get 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 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 New Commits on PTU # counts the commits to ptu/global.ini during the last 24 hours + + - name: Show New Commits On LIVE # counts the commits to live/global.ini during the last 24 hours + id: show_new_commits_live + run: echo ${{ steps.new_commits_live.outputs.NEW_COMMIT_COUNT_LIVE }} + + - name: Count New Commits On PTU id: new_commits_ptu run: echo "NEW_COMMIT_COUNT_PTU=$(git log --oneline --since '24 hours ago' -- ptu/global.ini | wc -l)" >> $GITHUB_OUTPUT - - id: date - run: echo "date=$(date '+%d.%m.%y')" >> $GITHUB_OUTPUT + + - name: Show New Commits On PTU + id: show_new_commits_ptu + run: echo ${{ steps.new_commits_ptu.outputs.NEW_COMMIT_COUNT_PTU }} + + - name: Get Date + id: date + run: echo "DATE=$(date '+%d.%m.%y')" >> $GITHUB_OUTPUT + + - name: Show Date + id: show_date + run: echo ${{ steps.date.outputs.DATE }} + + - 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: | + 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=Star Citizen $(git log -1 --pretty=%s -- live/global.ini | cut -s -d'|' -f1 | rev | cut -c 2- | rev) [de]" >> $GITHUB_OUTPUT + fi + + - name: Show Release Title For LIVE + id: show_title_live + run: echo ${{ steps.title_live.outputs.RELEASE_TITLE_LIVE }} + + - 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: | + 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=Star Citizen $(git log -1 --pretty=%s -- ptu/global.ini | cut -s -d'|' -f1 | rev | cut -c 2- | rev) [de]" >> $GITHUB_OUTPUT + fi + + - name: Show Release Title For PTU + id: show_title_ptu + run: echo ${{ steps.title_ptu.outputs.RELEASE_TITLE_PTU }} live_release: # runs only when live/global.ini was changed in the last 24 hours - name: Create Live Release + name: Create LIVE Release runs-on: ubuntu-latest - concurrency: - group: releases - cancel-in-progress: false needs: get_context_info if: needs.get_context_info.outputs.NEW_COMMIT_COUNT_LIVE > 0 permissions: contents: write steps: - - name: Checkout code + - name: Checkout Code uses: actions/checkout@v3 - - name: Create Release Zip + - name: Create ZIP For LIVE run: | sudo timedatectl set-timezone Europe/Berlin mkdir release @@ -58,33 +112,30 @@ jobs: mkdir -p "release/data/Localization/german_(germany)" cp "live/global.ini" "release/data/Localization/german_(germany)/" cd release - echo "${{ vars.VERSION_FILE_TEXT_LIVE }} $(date '+%d.%m.%y - %H:%M Uhr')" >> Version.txt + echo "${{ vars.VERSION_FILE_TEXT_LIVE }} ${{ needs.get_context_info.outputs.RELEASE_TITLE_LIVE }} $(date '+%d.%m.%y - %H:%M Uhr')" >> Version.txt zip -r -9 "../${{ vars.ZIP_NAME_LIVE }}" * - - name: Create New Release + - name: Create Release For LIVE uses: ncipollo/release-action@v1 with: - tag: ${{ needs.get_context_info.outputs.DATE }}-LIVE + tag: ${{ github.run_number }}-LIVE commit: main - name: ${{ vars.RELEASE_TITLE_LIVE }} + name: ${{ needs.get_context_info.outputs.RELEASE_TITLE_LIVE }} body: ${{ vars.RELEASE_BODY_LIVE }} artifacts: ${{ vars.ZIP_NAME_LIVE }} ptu_release: # runs only when ptu/global.ini was changed in the last 24 hours name: Create PTU Release runs-on: ubuntu-latest - concurrency: - group: releases - cancel-in-progress: false - needs: get_context_info - if: (vars.TRIGGER_PTU_RELEASE == 1 && needs.get_context_info.outputs.NEW_COMMIT_COUNT_PTU > 0) + needs: [get_context_info, live_release] + if: ${{ always() }} && (vars.TRIGGER_PTU_RELEASE == 1 && (needs.get_context_info.outputs.NEW_COMMIT_COUNT_PTU > 0)) permissions: contents: write steps: - - name: Checkout code + - name: Checkout Code uses: actions/checkout@v3 - - name: Create Release Zip + - name: Create ZIP For PTU run: | sudo timedatectl set-timezone Europe/Berlin mkdir release @@ -92,15 +143,15 @@ jobs: mkdir -p "release/data/Localization/german_(germany)" cp "ptu/global.ini" "release/data/Localization/german_(germany)/" cd release - echo "${{ vars.VERSION_FILE_TEXT_PTU }} $(date '+%d.%m.%y - %H:%M Uhr')" >> Version.txt + echo "${{ vars.VERSION_FILE_TEXT_PTU }} ${{ needs.get_context_info.outputs.RELEASE_TITLE_PTU }} $(date '+%d.%m.%y - %H:%M Uhr')" >> Version.txt zip -r -9 "../${{ vars.ZIP_NAME_PTU }}" * - - name: Create New Release + - name: Create Release For PTU uses: ncipollo/release-action@v1 with: - tag: ${{ needs.get_context_info.outputs.DATE }}-PTU + tag: ${{ github.run_number }}-PTU commit: main - name: ${{ vars.RELEASE_TITLE_PTU }} + name: ${{ needs.get_context_info.outputs.RELEASE_TITLE_PTU }} body: ${{ vars.RELEASE_BODY_PTU }} artifacts: ${{ vars.ZIP_NAME_PTU }} - makeLatest: "latest" + makeLatest: true