]> git.lizzy.rs Git - rust.git/blob - .github/workflows/release.yaml
Merge #7047
[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     - trigger-nightly
10
11 env:
12   CARGO_INCREMENTAL: 0
13   CARGO_NET_RETRY: 10
14   RUSTFLAGS: "-D warnings -W unreachable-pub"
15   RUSTUP_MAX_RETRIES: 10
16
17 jobs:
18   dist-windows:
19     name: dist (Windows)
20     runs-on: windows-latest
21     env:
22       RA_TARGET: x86_64-pc-windows-msvc
23
24     steps:
25     - name: Checkout repository
26       uses: actions/checkout@v2
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
33       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
34
35     - name: Install Rust toolchain
36       uses: actions-rs/toolchain@v1
37       with:
38         toolchain: stable
39         profile: minimal
40         override: true
41
42     - name: Dist
43       run: cargo xtask dist
44
45     - name: Upload artifacts
46       uses: actions/upload-artifact@v1
47       with:
48         name: dist-windows-latest
49         path: ./dist
50
51   dist-ubuntu:
52     name: dist (Ubuntu 16.04)
53     runs-on: ubuntu-16.04
54     env:
55       RA_TARGET: x86_64-unknown-linux-gnu
56
57     steps:
58     - name: Checkout repository
59       uses: actions/checkout@v2
60
61     - name: Install Rust toolchain
62       uses: actions-rs/toolchain@v1
63       with:
64         toolchain: stable
65         profile: minimal
66         override: true
67
68     - name: Install Nodejs
69       uses: actions/setup-node@v1
70       with:
71         node-version: 12.x
72
73     - name: Dist
74       if: github.ref == 'refs/heads/release'
75       run: cargo xtask dist --client 0.2.$GITHUB_RUN_NUMBER
76
77     - name: Dist
78       if: github.ref != 'refs/heads/release'
79       run: cargo xtask dist --nightly --client 0.3.$GITHUB_RUN_NUMBER-nightly
80
81     - name: Nightly analysis-stats check
82       if: github.ref != 'refs/heads/release'
83       run: target/${{ env.RA_TARGET }}/release/rust-analyzer analysis-stats .
84
85     - name: Upload artifacts
86       uses: actions/upload-artifact@v1
87       with:
88         name: dist-ubuntu-16.04
89         path: ./dist
90
91   dist-macos-latest:
92     name: dist (MacOS latest)
93     runs-on: macos-latest
94     env:
95       RA_TARGET: x86_64-apple-darwin
96
97     steps:
98     - name: Checkout repository
99       uses: actions/checkout@v2
100
101     - name: Install Rust toolchain
102       uses: actions-rs/toolchain@v1
103       with:
104         toolchain: stable
105         profile: minimal
106         override: true
107
108     - name: Dist
109       run: cargo xtask dist
110
111     - name: Upload artifacts
112       uses: actions/upload-artifact@v1
113       with:
114         name: dist-macos-latest
115         path: ./dist
116
117   dist-macos-11:
118     name: dist (MacOS 11.0)
119     runs-on: macos-11.0
120     env:
121       RA_TARGET: aarch64-apple-darwin
122
123     steps:
124     - name: Checkout repository
125       uses: actions/checkout@v2
126
127     - name: Install Rust toolchain (beta)
128       uses: actions-rs/toolchain@v1
129       with:
130         toolchain: beta
131         target: aarch64-apple-darwin
132         profile: minimal
133         override: true
134
135     - name: Dist
136       run: cargo xtask dist
137
138     - name: Upload artifacts
139       uses: actions/upload-artifact@v1
140       with:
141         name: dist-macos-11.0
142         path: ./dist
143
144   publish:
145     name: publish
146     runs-on: ubuntu-16.04
147     needs: ['dist-windows', 'dist-ubuntu', 'dist-macos-latest', 'dist-macos-11']
148     steps:
149     - name: Install Nodejs
150       uses: actions/setup-node@v1
151       with:
152         node-version: 12.x
153
154     - run: echo "TAG=$(date --iso --utc)" >> $GITHUB_ENV
155       if: github.ref == 'refs/heads/release'
156     - run: echo "TAG=nightly" >> $GITHUB_ENV
157       if: github.ref != 'refs/heads/release'
158     - run: 'echo "TAG: $TAG"'
159
160     - name: Checkout repository
161       uses: actions/checkout@v2
162
163     - run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
164     - run: 'echo "HEAD_SHA: $HEAD_SHA"'
165
166     - uses: actions/download-artifact@v1
167       with:
168         name: dist-macos-11.0
169         path: dist
170     - uses: actions/download-artifact@v1
171       with:
172         name: dist-macos-latest
173         path: dist
174     - uses: actions/download-artifact@v1
175       with:
176         name: dist-ubuntu-16.04
177         path: dist
178     - uses: actions/download-artifact@v1
179       with:
180         name: dist-windows-latest
181         path: dist
182     - run: ls -al ./dist
183
184     - name: Publish Release
185       uses: ./.github/actions/github-release
186       with:
187         files: "dist/*"
188         name: ${{ env.TAG }}
189         token: ${{ secrets.GITHUB_TOKEN }}
190
191     - run: npm ci
192       working-directory: ./editors/code
193
194     - name: Publish Extension
195       if: github.ref == 'refs/heads/release'
196       working-directory: ./editors/code
197       # token from https://dev.azure.com/rust-analyzer/
198       run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer.vsix