From cdd1abbefef66bf644394fa0e69d2c2100dd0a38 Mon Sep 17 00:00:00 2001 From: LukeZGD <26163116+LukeZGD@users.noreply.github.com> Date: Thu, 18 Aug 2022 13:43:39 +0800 Subject: [PATCH] Better versioning --- .github/workflows/build.yml | 25 +++++++++++++++---------- restore.sh | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 204dcfb..3d01451 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,8 +6,13 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Create git_hash - run: echo ${{ github.sha }} | tee ./resources/git_hash + - name: Create name version env + run: | + echo "DATE=$(date +%Y-%m-%d)" >> $GITHUB_ENV + echo "SHA_SHORT=$(echo ${{ github.sha }} | cut -c -7)" >> $GITHUB_ENV + + - name: Create git hash + run: echo "${{ env.DATE }}-${{ env.SHA_SHORT }}" | tee ./resources/git_hash - name: Move linux binaries run: | @@ -23,7 +28,7 @@ jobs: chmod +x ./resources/libimobiledevice_macos/* - name: Zip macos files - run: zip -r ${{ github.event.repository.name }}_macos.zip resources/ restore.sh README.md + run: zip -r ${{ github.event.repository.name }}_macos_${{ env.DATE }}-${{ env.SHA_SHORT }}.zip resources/ restore.sh README.md - name: Move macos binaries run: | @@ -40,7 +45,7 @@ jobs: chmod +x ./resources/libimobiledevice_linux/* - name: Zip linux files - run: zip -r ${{ github.event.repository.name }}_linux.zip resources/ restore.sh README.md + run: zip -r ${{ github.event.repository.name }}_linux_${{ env.DATE }}-${{ env.SHA_SHORT }}.zip resources/ restore.sh README.md - name: Move linux binaries and other files run: | @@ -61,7 +66,7 @@ jobs: unzip tools_win.zip -d ./resources - name: Zip win files - run: zip -r ${{ github.event.repository.name }}_win.zip resources/ restore.cmd restore.sh README.md + run: zip -r ${{ github.event.repository.name }}_win_${{ env.DATE }}-${{ env.SHA_SHORT }}.zip resources/ restore.cmd restore.sh README.md - name: Copy exclude files back run: cp -r ./exclude/* ./resources @@ -70,7 +75,7 @@ jobs: run: ./resources/complete.sh - name: Zip complete files - run: zip -r ${{ github.event.repository.name }}_complete.zip resources/ restore.cmd restore.sh README.md + run: zip -r ${{ github.event.repository.name }}_complete_${{ env.DATE }}-${{ env.SHA_SHORT }}.zip resources/ restore.cmd restore.sh README.md - name: Update latest release uses: pyTooling/Actions/releaser@main @@ -79,7 +84,7 @@ jobs: rm: true token: ${{ secrets.GITHUB_TOKEN }} files: | - ${{ github.event.repository.name }}_complete.zip - ${{ github.event.repository.name }}_macos.zip - ${{ github.event.repository.name }}_linux.zip - ${{ github.event.repository.name }}_win.zip + ${{ github.event.repository.name }}_complete_${{ env.DATE }}-${{ env.SHA_SHORT }}.zip + ${{ github.event.repository.name }}_macos_${{ env.DATE }}-${{ env.SHA_SHORT }}.zip + ${{ github.event.repository.name }}_linux_${{ env.DATE }}-${{ env.SHA_SHORT }}.zip + ${{ github.event.repository.name }}_win_${{ env.DATE }}-${{ env.SHA_SHORT }}.zip diff --git a/restore.sh b/restore.sh index 4d27d87..b888794 100755 --- a/restore.sh +++ b/restore.sh @@ -81,7 +81,7 @@ Main() { fi if [[ -d .git ]]; then - Echo "Version: $(git rev-parse HEAD)" + Echo "Version: $(git log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%d)-$(git rev-parse HEAD | cut -c -7)" elif [[ -e resources/git_hash ]]; then Echo "Version: $(cat resources/git_hash)" else