浏览代码

determine revision number via `git rev-list --count HEAD`

Sebastian Stenzel 3 年之前
父节点
当前提交
d5588b9739
共有 1 个文件被更改,包括 35 次插入31 次删除
  1. 35 31
      .github/workflows/build.yml

+ 35 - 31
.github/workflows/build.yml

@@ -130,23 +130,37 @@ jobs:
           if-no-files-found: error
 
 #
-# Linux AppImage
-# 
+# Release Metadata
+#
 
-  linux-appimage:
+  metadata:
     name: Build AppImage
     runs-on: ubuntu-latest
-    needs: [buildkit, jlink]
+    needs: test
     steps:
       - uses: actions/checkout@v2
-      - name: Set version
-        id: setversion
-        run: |
+        with:
+          fetch-depth: 0
+      - run: |
           if [[ $GITHUB_REF == refs/tags/* ]]; then
-            echo "BUILD_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
+            echo "::set-output name=versionStr::${GITHUB_REF##*/}"
+            echo "::set-output name=versionNum::${GITHUB_REF##*/}"
           else
-            echo "BUILD_VERSION=SNAPSHOT" >> $GITHUB_ENV
+            echo "::set-output name=versionStr::SNAPSHOT"
+            echo "::set-output name=versionNum::99.0.0"
           fi
+          echo "::set-output name=revNum::`git rev-list --count HEAD`"
+          
+#
+# Linux AppImage
+# 
+
+  linux-appimage:
+    name: Build AppImage
+    runs-on: ubuntu-latest
+    needs: [buildkit, jlink, metadata]
+    steps:
+      - uses: actions/checkout@v2
       - name: Download buildkit-linux
         uses: actions/download-artifact@v2
         with:
@@ -174,7 +188,7 @@ jobs:
           ln -s usr/share/applications/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/Cryptomator.desktop
           ln -s bin/cryptomator.sh Cryptomator.AppDir/AppRun
         env:
-          REVISION_NO: ${{ github.run_id }}
+          REVISION_NO: ${{ needs.metadata.outputs.revNum }}
       - name: Download AppImageKit
         run: |
           curl -L https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage -o appimagetool.AppImage
@@ -189,22 +203,22 @@ jobs:
           GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
       - name: Build AppImage
         run: >
-          ./squashfs-root/AppRun Cryptomator.AppDir cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage
+          ./squashfs-root/AppRun Cryptomator.AppDir cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage
           -u 'gh-releases-zsync|cryptomator|cryptomator|latest|cryptomator-*-x86_64.AppImage.zsync'
           --sign --sign-key=615D449FE6E6A235 --sign-args="--batch --pinentry-mode loopback"
       - name: Create Detached GPG Signature
         run: |
-          gpg --batch --quiet --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage
-          gpg --batch --quiet --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage.zsync
+          gpg --batch --quiet --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage
+          gpg --batch --quiet --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.zsync
       - name: Upload AppImage
         uses: actions/upload-artifact@v2
         with:
           name: appimage
           path: |
-            cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage
-            cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage.asc
-            cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage.zsync
-            cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage.zsync.asc
+            cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage
+            cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.asc
+            cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.zsync
+            cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.zsync.asc
           if-no-files-found: error
 
 #
@@ -212,24 +226,14 @@ jobs:
 #
 
   windows-appdir:
-    name: Build App Directory
+    name: Build Windows App Directory
     runs-on: windows-latest
-    needs: [buildkit, jlink]
+    needs: [buildkit, jlink, metadata]
     steps:
       - uses: actions/checkout@v2
       - uses: actions/setup-java@v1
         with:
           java-version: ${{ env.JAVA_VERSION }}
-      - name: Set version
-        id: setversion
-        run: |
-          if [[ $GITHUB_REF == refs/tags/* ]]; then
-            echo "BUILD_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
-            echo "NUMERIC_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
-          else
-            echo "BUILD_VERSION=SNAPSHOT" >> $GITHUB_ENV
-            echo "NUMERIC_VERSION=99.0.0" >> $GITHUB_ENV
-          fi
       - name: Download buildkit-win
         uses: actions/download-artifact@v2
         with:
@@ -252,7 +256,7 @@ jobs:
           --name Cryptomator
           --vendor "Skymatic GmbH"
           --copyright "(C) 2016 - 2021 Skymatic GmbH"
-          --app-version "${{ env.NUMERIC_VERSION }}.${{ github.run_id }}"
+          --app-version "${{ needs.metadata.outputs.versionNum }}.${{ needs.metadata.outputs.revNum }}"
           --icon dist/msi/resources/app/Cryptomator.ico
           --java-options "-Dfile.encoding=\"utf-8\""
           --java-options "-Dcryptomator.logDir=\"~/AppData/Roaming/Cryptomator\""
@@ -261,7 +265,7 @@ jobs:
           --java-options "-Dcryptomator.keychainPath=\"~/AppData/Roaming/Cryptomator/keychain.json\""
           --java-options "-Dcryptomator.mountPointsDir=\"~/Cryptomator\""
           --java-options "-Dcryptomator.showTrayIcon=true"
-          --java-options "-Dcryptomator.buildNumber=\"msi-${{ github.run_id }}\""
+          --java-options "-Dcryptomator.buildNumber=\"msi-${{ needs.metadata.outputs.revNum }}\""
           --java-options "-Xss2m"
           --java-options "-Xmx256m"
           --module org.cryptomator.desktop/org.cryptomator.launcher.Cryptomator