-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (125 loc) · 3.55 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Release
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
name: Linting (rustfmt + clippy)
permissions:
checks: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install rustup components (rustfmt, clippy)
run: rustup component add rustfmt clippy
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- uses: giraffate/clippy-action@v1
with:
reporter: "github-pr-review"
github_token: ${{ secrets.GITHUB_TOKEN }}
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Run all tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
tag:
name: Tag & Publish
needs: [lint, test]
permissions:
contents: write
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.crate-version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Crate Version
id: crate-version
uses: colathro/crate-version@1.0.0
with:
file: "./Cargo.toml"
- uses: mukunku/tag-exists-action@v1.6.0
id: check-tag
with:
tag: v${{ steps.crate-version.outputs.version }}
- name: Fail if tag already exists
if: ${{ steps.check-tag.outputs.exists == 'true' }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('Tag already exists')
- name: Push the crate version as a tag
id: tag_version
uses: mathieudutour/github-tag-action@v5.4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: "v"
custom_tag: ${{ steps.crate-version.outputs.version }}
create-release:
needs: tag
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: taiki-e/create-gh-release-action@v1
with:
changelog: "./CHANGELOG.md"
token: ${{ secrets.GITHUB_TOKEN }}
ref: "refs/tags/v${{needs.tag.outputs.tag}}"
upload-assets:
needs: [tag, create-release]
permissions:
contents: write
strategy:
matrix:
include:
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: universal-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: taiki-e/upload-rust-binary-action@v1
with:
bin: crates-lsp
target: ${{ matrix.target }}
token: ${{ secrets.GITHUB_TOKEN }}
ref: "refs/tags/v${{needs.tag.outputs.tag}}"