Add a release upload action

Nathan Sobo created

Change summary

.github/workflows/ci.yml | 50 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 3 deletions(-)

Detailed changes

.github/workflows/ci.yml 🔗

@@ -14,7 +14,7 @@ env:
 
 jobs:
   tests:
-    name: Tests
+    name: Run tests
     runs-on: self-hosted
     steps:
       - name: Checkout repo
@@ -47,9 +47,53 @@ jobs:
       - name: Run tests
         run: cargo test --no-fail-fast
 
-      - name: Create and upload app bundle
+  bundle:
+    name: Bundle app
+    runs-on: self-hosted
+    steps:
+      - name: Checkout repo
+        uses: actions/checkout@v2
+
+      # Work around https://github.com/actions/cache/issues/403.
+      - name: Use GNU tar
+        run: |
+          echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
+
+      - name: Cache artifacts
+        id: cache
+        uses: actions/cache@v2
+        with:
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.rustup
+            target
+          key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
+
+      - name: Install Rust
+        if: steps.cache.outputs.cache-hit != 'true'
+        uses: actions-rs/toolchain@v1
+        with:
+          toolchain: stable
+          target: x86_64-apple-darwin
+          profile: minimal
+
+      - name: Create app bundle
         run: script/bundle
-      - uses: actions/upload-artifact@v2
+
+      - name: Upload app bundle to workflow run
+        uses: actions/upload-artifact@v2
         with:
           name: Zed.dmg
           path: target/release/Zed.dmg
+
+      - uses: svenstaro/upload-release-action@v2
+        name: Upload app bundle to release
+        if: ${{ startsWith(github.github.ref, 'refs/tags/v') }}
+        with:
+          repo_token: ${{ secrets.GITHUB_TOKEN }}
+          file: target/release/Zed.dmg
+          asset_name: Zed.dmg
+          tag: ${{ github.ref }}
+          overwrite: true
+          body: ""