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: Checkout repo
35        uses: actions/checkout@v2
36        with:
37          clean: false
38
39      - name: Run tests
40        run: cargo test --workspace --no-fail-fast
41
42  bundle:
43    name: Bundle app
44    runs-on:
45        - self-hosted
46        - bundle
47    env:
48      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
49      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
50      APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
51      APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
52    steps:
53      - name: Install Rust x86_64-apple-darwin target
54        uses: actions-rs/toolchain@v1
55        with:
56          toolchain: stable
57          target: x86_64-apple-darwin
58          profile: minimal
59
60      - name: Install Rust aarch64-apple-darwin target
61        uses: actions-rs/toolchain@v1
62        with:
63          toolchain: stable
64          target: aarch64-apple-darwin
65          profile: minimal
66
67      - name: Checkout repo
68        uses: actions/checkout@v2
69        with:
70          clean: false
71
72      - name: Validate version
73        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
74        run: script/validate-version
75
76      - name: Create app bundle
77        run: script/bundle
78
79      - name: Upload app bundle to workflow run if main branch
80        uses: actions/upload-artifact@v2
81        if: ${{ github.ref == 'refs/heads/main' }}
82        with:
83          name: Zed.dmg
84          path: target/release/Zed.dmg
85
86      - uses: softprops/action-gh-release@v1
87        name: Upload app bundle to release if release tag
88        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
89        with:
90          draft: true
91          files: target/release/Zed.dmg
92          overwrite: true
93          body: ""
94        env:
95          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}