-
Notifications
You must be signed in to change notification settings - Fork 3
141 lines (133 loc) Β· 4 KB
/
main.yml
File metadata and controls
141 lines (133 loc) Β· 4 KB
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: Main
on: push
jobs:
codestyle:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
with:
components: rustfmt
rust-version: nightly
- uses: actions/checkout@v2
- run: cargo fmt --all -- --check
lint:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
with:
components: clippy
- uses: actions/checkout@v2
- run: cargo clippy --all-targets --all-features -- -D clippy::all
compile:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@v2
- run: cargo check --all
test:
needs: [codestyle, lint, compile]
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
rust: [stable]
runs-on: ${{ matrix.os }}
steps:
- name: Setup Rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- name: Checkout
uses: actions/checkout@v2
- name: Test
run: cargo test
release:
needs: [test]
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
include:
- os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
bin: 'devtogo'
name: 'devtogo-Linux-x86_64.tar.gz'
- os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
bin: 'devtogo.exe'
name: 'devtogo-Windows-x86_64.zip'
- os: macOS-latest
rust: stable
target: x86_64-apple-darwin
bin: 'devtogo'
name: 'devtogo-Darwin-x86_64.tar.gz'
runs-on: ${{ matrix.os }}
steps:
- name: Setup Rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- name: Setup musl-gcc
if: contains(matrix.target, 'musl')
run: |
sudo apt-get install musl-tools
- name: Checkout
uses: actions/checkout@v2
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
strip target/${{ matrix.target }}/release/${{ matrix.bin }}
cd target/${{ matrix.target }}/release
if [[ "${{ matrix.os }}" == "windows-latest" ]]
then
7z a ../../../${{ matrix.name }} ${{ matrix.bin }}
else
tar czvf ../../../${{ matrix.name }} ${{ matrix.bin }}
fi
cd -
- name: Publish
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: 'devtogo*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Brew Bump
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'macos-latest' && env.HOMEBREW_GITHUB_API_TOKEN
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
run: |
SHA256=$(shasum -a 256 ${{ matrix.name }} | awk '{printf $1}')
VERSION=${GITHUB_REF#refs/tags/}
echo "SHA256 ${SHA256}"
echo "VERSION ${VERSION}"
brew tap softprops/tools
brew bump-formula-pr \
-f \
--version=${VERSION} \
--no-browse \
--no-audit \
--sha256=${SHA256} \
--url="https://github.com/softprops/devtogo/releases/download/${VERSION}/${{ matrix.name }}" \
softprops/tools/devtogo
publish-crate:
if: startsWith(github.ref, 'refs/tags/')
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@v1
- name: Publish
if: startsWith(github.ref, 'refs/tags/') && env.CRATES_TOKEN
shell: bash
run: cargo publish --token ${{ env.CRATES_TOKEN }}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}