Merge pull request #66 from zed-industries/upload-release

Nathan Sobo created

Add a release upload action

Change summary

.github/workflows/ci.yml | 65 ++++++++++++++++++++++++++++-------------
script/bundle            |  3 +
2 files changed, 47 insertions(+), 21 deletions(-)

Detailed changes

.github/workflows/ci.yml 🔗

@@ -4,6 +4,8 @@ on:
   push:
     branches:
       - master
+    tags:
+      - "v*"
   pull_request:
     branches:
       - "**"
@@ -14,42 +16,63 @@ env:
 
 jobs:
   tests:
-    name: Tests
+    name: Run tests
     runs-on: self-hosted
     steps:
+      - name: Install Rust
+        uses: actions-rs/toolchain@v1
+        with:
+          toolchain: stable
+          target: x86_64-apple-darwin
+          profile: minimal
+
       - name: Checkout repo
         uses: actions/checkout@v2
+        with:
+          clean: false
 
-      # 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: Run tests
+        run: cargo test --no-fail-fast
 
-      - name: Cache artifacts
-        id: cache
-        uses: actions/cache@v2
+  bundle:
+    name: Bundle app
+    runs-on: self-hosted
+    steps:
+      - name: Install Rust x86_64-apple-darwin target
+        uses: actions-rs/toolchain@v1
         with:
-          path: |
-            ~/.cargo/registry
-            ~/.cargo/git
-            ~/.rustup
-            target
-          key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
+          toolchain: stable
+          target: x86_64-apple-darwin
+          profile: minimal
 
-      - name: Install Rust
-        if: steps.cache.outputs.cache-hit != 'true'
+      - name: Install Rust aarch64-apple-darwin target
         uses: actions-rs/toolchain@v1
         with:
           toolchain: stable
-          target: x86_64-apple-darwin
+          target: aarch64-apple-darwin
           profile: minimal
 
-      - name: Run tests
-        run: cargo test --no-fail-fast
+      - name: Checkout repo
+        uses: actions/checkout@v2
+        with:
+          clean: false
 
-      - name: Create and upload app bundle
+      - 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.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: ""

script/bundle 🔗

@@ -2,6 +2,9 @@
 
 set -e
 
+# Install cargo-bundle 0.5.0 if it's not already installed
+cargo install cargo-bundle --version 0.5.0
+
 # Build the app bundle for x86_64
 pushd zed > /dev/null
 cargo bundle --release --target x86_64-apple-darwin