ci.yml

  1name: CI
  2
  3on:
  4  push:
  5    branches:
  6      - main
  7    tags:
  8      - "v*"
  9  pull_request:
 10    branches:
 11      - "**"
 12
 13env:
 14  CARGO_TERM_COLOR: always
 15  CARGO_INCREMENTAL: 0
 16  RUST_BACKTRACE: 1
 17
 18jobs:
 19  tests:
 20    name: Run tests
 21    runs-on:
 22      - self-hosted
 23      - test
 24    env:
 25      RUSTFLAGS: -D warnings
 26    steps:
 27      - name: Install Rust
 28        uses: actions-rs/toolchain@v1
 29        with:
 30          toolchain: stable
 31          target: x86_64-apple-darwin
 32          profile: minimal
 33
 34      - name: Install Node
 35        uses: actions/setup-node@v2
 36        with:
 37          node-version: '16'
 38
 39      - name: Checkout repo
 40        uses: actions/checkout@v2
 41        with:
 42          clean: false
 43
 44      - name: Run tests
 45        run: cargo test --workspace --no-fail-fast
 46
 47  bundle:
 48    name: Bundle app
 49    runs-on:
 50      - self-hosted
 51      - bundle
 52    env:
 53      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
 54      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
 55      APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
 56      APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
 57    steps:
 58      - name: Install Rust x86_64-apple-darwin target
 59        uses: actions-rs/toolchain@v1
 60        with:
 61          toolchain: stable
 62          target: x86_64-apple-darwin
 63          profile: minimal
 64
 65      - name: Install Rust aarch64-apple-darwin target
 66        uses: actions-rs/toolchain@v1
 67        with:
 68          toolchain: stable
 69          target: aarch64-apple-darwin
 70          profile: minimal
 71
 72      - name: Install Node
 73        uses: actions/setup-node@v2
 74        with:
 75          node-version: '16'
 76
 77      - name: Checkout repo
 78        uses: actions/checkout@v2
 79        with:
 80          clean: false
 81
 82      - name: Validate version
 83        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
 84        run: script/validate-version
 85
 86      - name: Create app bundle
 87        run: script/bundle
 88
 89      - name: Upload app bundle to workflow run if main branch
 90        uses: actions/upload-artifact@v2
 91        if: ${{ github.ref == 'refs/heads/main' }}
 92        with:
 93          name: Zed.dmg
 94          path: target/release/Zed.dmg
 95
 96      - uses: softprops/action-gh-release@v1
 97        name: Upload app bundle to release if release tag
 98        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
 99        with:
100          draft: true
101          files: target/release/Zed.dmg
102          overwrite: true
103          body: ""
104        env:
105          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}