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        run: |
 29          rustup set profile minimal
 30          rustup update stable
 31          rustup target add wasm32-wasi
 32
 33      - name: Install Node
 34        uses: actions/setup-node@v2
 35        with:
 36          node-version: '16'
 37
 38      - name: Checkout repo
 39        uses: actions/checkout@v2
 40        with:
 41          clean: false
 42          submodules: 'recursive'
 43            
 44      - name: Run tests
 45        run: cargo test --workspace --no-fail-fast
 46    
 47      - name: Build collab binaries
 48        run: cargo build --bins --all-features 
 49
 50  bundle:
 51    name: Bundle app
 52    runs-on:
 53      - self-hosted
 54      - bundle
 55    if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
 56    needs: tests
 57    env:
 58      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
 59      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
 60      APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
 61      APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
 62      ZED_AMPLITUDE_API_KEY: ${{ secrets.ZED_AMPLITUDE_API_KEY }}
 63      ZED_MIXPANEL_TOKEN: ${{ secrets.ZED_MIXPANEL_TOKEN }}
 64    steps:
 65      - name: Install Rust
 66        run: |
 67          rustup set profile minimal
 68          rustup update stable
 69          rustup target add aarch64-apple-darwin
 70          rustup target add x86_64-apple-darwin
 71          rustup target add wasm32-wasi
 72
 73      - name: Install Node
 74        uses: actions/setup-node@v2
 75        with:
 76          node-version: '16'
 77
 78      - name: Checkout repo
 79        uses: actions/checkout@v2
 80        with:
 81          clean: false
 82          submodules: 'recursive'
 83
 84      - name: Determine version and release channel
 85        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
 86        run: |
 87          set -eu
 88
 89          version=$(script/get-crate-version zed)
 90          channel=$(cat crates/zed/RELEASE_CHANNEL)
 91          echo "Publishing version: ${version} on release channel ${channel}"
 92          echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
 93
 94          expected_tag_name=""
 95          case ${channel} in
 96            stable)
 97              expected_tag_name="v${version}";;
 98            preview)
 99              expected_tag_name="v${version}-pre";;
100            *)
101              echo "can't publish a release on channel ${channel}"
102              exit 1;;
103          esac
104          if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
105            echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
106            exit 1
107          fi
108
109      - name: Create app bundle
110        run: script/bundle
111
112      - name: Upload app bundle to workflow run if main branch
113        uses: actions/upload-artifact@v2
114        if: ${{ github.ref == 'refs/heads/main' }}
115        with:
116          name: Zed.dmg
117          path: target/release/Zed.dmg
118
119      - uses: softprops/action-gh-release@v1
120        name: Upload app bundle to release
121        if: ${{ github.env.RELEASE_CHANNEL }}
122        with:
123          draft: true
124          prerelease: ${{ github.env.RELEASE_CHANNEL == 'preview' }}
125          files: target/release/Zed.dmg
126          overwrite: true
127          body: ""
128        env:
129          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}