]> git.lizzy.rs Git - rust.git/blob - .github/workflows/release.yaml
d58be0fd77aa85f38e859f40c70163acf17b4801
[rust.git] / .github / workflows / release.yaml
1 name: release
2 on:
3   schedule:
4   - cron: '0 0 * * *' # midnight UTC
5
6   push:
7     branches:
8     - release
9
10 jobs:
11   dist:
12     name: dist
13     runs-on: ${{ matrix.os }}
14     strategy:
15       matrix:
16         os: [ubuntu-latest, windows-latest, macos-latest]
17
18     env:
19       RUSTFLAGS: -D warnings
20       CARGO_INCREMENTAL: 0
21       RUSTUP_MAX_RETRIES: 10
22       CARGO_NET_RETRY: 10
23
24     steps:
25     - name: Checkout repository
26       uses: actions/checkout@v1
27
28     # We need to disable the existing toolchain to avoid updating rust-docs
29     # which takes a long time. The fastest way to do this is to rename the
30     # existing folder, as deleting it takes about as much time as not doing
31     # anything and just updating rust-docs.
32     - name: Rename existing rust toolchain (Windows)
33       if: matrix.os == 'windows-latest'
34       run: Rename-Item C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc.old
35
36     - name: Install Rust toolchain
37       uses: actions-rs/toolchain@v1
38       with:
39         toolchain: stable
40         profile: minimal
41         target: x86_64-unknown-linux-musl
42         override: true
43
44     - name: Install Nodejs
45       uses: actions/setup-node@v1
46       with:
47         node-version: 12.x
48
49     - name: Dist
50       if: github.event_name == 'push'
51       run: cargo xtask dist
52
53     - name: Dist
54       if: github.event_name != 'push'
55       run: cargo xtask dist --nightly
56
57     - name: Upload artifacts
58       uses: actions/upload-artifact@v1
59       with:
60         name: dist-${{ matrix.os }}
61         path: ./dist
62
63   publish:
64     name: publish
65     runs-on: ubuntu-latest
66     needs: ['dist']
67     steps:
68     - name: Install Nodejs
69       uses: actions/setup-node@v1
70       with:
71         node-version: 12.x
72
73     - run: echo "::set-env name=TAG::$(date --iso)"
74       if: github.event_name == 'push'
75     - run: echo "::set-env name=TAG::nightly"
76       if: github.event_name == 'schedule'
77     - run: 'echo "TAG: $TAG"'
78
79     - name: Checkout repository
80       uses: actions/checkout@v1
81
82     - uses: actions/download-artifact@v1
83       with:
84         name: dist-macos-latest
85         path: dist
86     - uses: actions/download-artifact@v1
87       with:
88         name: dist-ubuntu-latest
89         path: dist
90     - uses: actions/download-artifact@v1
91       with:
92         name: dist-windows-latest
93         path: dist
94     - run: ls -all ./dist
95
96     - name: Publish Release
97       uses: ./.github/actions/github-release
98       with:
99         files: "dist/*"
100         name: ${{ env.TAG }}
101         token: ${{ secrets.GITHUB_TOKEN }}
102
103     - run: npm ci
104       working-directory: ./editors/code
105
106     - name: Publish Extension
107       if: github.event_name == 'push'
108       working-directory: ./editors/code
109       # token from https://dev.azure.com/rust-analyzer/
110       run: npx vsce publish 0.1.$(date +%Y%m%d) --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer.vsix