ci.yml

  1name: CI
  2
  3on:
  4  push:
  5    branches:
  6      - main
  7      - "v*"
  8    tags:
  9      - "v*"
 10  pull_request:
 11    branches:
 12      - "**"
 13
 14env:
 15  CARGO_TERM_COLOR: always
 16  CARGO_INCREMENTAL: 0
 17  RUST_BACKTRACE: 1
 18
 19jobs:
 20  tests:
 21    name: Run tests
 22    runs-on:
 23      - self-hosted
 24      - test
 25    env:
 26      RUSTFLAGS: -D warnings
 27    steps:
 28      - name: Install Rust
 29        run: |
 30          rustup set profile minimal
 31          rustup update stable
 32          rustup target add wasm32-wasi
 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          submodules: 'recursive'
 44            
 45      - name: Run tests
 46        run: cargo test --workspace --no-fail-fast
 47    
 48      - name: Build collab binaries
 49        run: cargo build --bins --all-features 
 50
 51  bundle:
 52    name: Bundle app
 53    runs-on:
 54      - self-hosted
 55      - bundle
 56    if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
 57    needs: tests
 58    env:
 59      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
 60      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
 61      APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
 62      APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
 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: ${{ env.RELEASE_CHANNEL }}
122        with:
123          draft: true
124          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
125          files: target/release/Zed.dmg
126          body: ""
127        env:
128          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}