1
- name : Release & Publish
1
+ name : Test & Publish
2
2
3
3
on :
4
4
workflow_dispatch : # enable manual triggering
7
7
- ' v[0-9]+.*'
8
8
9
9
env :
10
- CARGO_TERM_COLOR : always
11
- RUSTFLAGS : " -Dwarnings"
12
10
BINARY_NAME : " domain-checker"
13
11
14
12
jobs :
15
- # First job: Test and publish to crates.io
16
13
test-and-publish :
17
14
name : Test and publish to crates.io
18
15
runs-on : ubuntu-latest
@@ -28,150 +25,10 @@ jobs:
28
25
- name : Run tests
29
26
run : cargo test --verbose
30
27
31
- # - name: Check formatting
32
- # run: cargo fmt --all -- --check
33
-
34
28
- name : Run clippy
35
29
run : cargo clippy --all-targets --all-features
36
30
37
31
- name : Publish to crates.io
38
32
run : cargo publish --token ${CRATES_TOKEN}
39
33
env :
40
34
CRATES_TOKEN : ${{ secrets.CRATES_TOKEN }}
41
-
42
- # Second job: Build binaries for different platforms
43
- build-release :
44
- name : Build Release - ${{ matrix.platform.os_name }}
45
- needs : test-and-publish
46
- runs-on : ${{ matrix.platform.runs_on }}
47
- strategy :
48
- matrix :
49
- platform :
50
- - os_name : Linux-x86_64
51
- runs_on : ubuntu-latest
52
- target : x86_64-unknown-linux-gnu
53
- bin_extension : " "
54
- compress_format : tar.gz
55
- cross : false
56
-
57
- - os_name : Linux-aarch64
58
- runs_on : ubuntu-latest
59
- target : aarch64-unknown-linux-gnu
60
- bin_extension : " "
61
- compress_format : tar.gz
62
- cross : true
63
-
64
- - os_name : Windows-x86_64
65
- runs_on : windows-latest
66
- target : x86_64-pc-windows-msvc
67
- bin_extension : .exe
68
- compress_format : zip
69
- cross : false
70
-
71
- - os_name : macOS-x86_64
72
- runs_on : macos-latest
73
- target : x86_64-apple-darwin
74
- bin_extension : " "
75
- compress_format : tar.gz
76
- cross : false
77
-
78
- - os_name : macOS-aarch64
79
- runs_on : macos-latest
80
- target : aarch64-apple-darwin
81
- bin_extension : " "
82
- compress_format : tar.gz
83
- cross : true
84
-
85
- steps :
86
- - uses : actions/checkout@v4
87
-
88
- - name : Install Rust toolchain
89
- uses : dtolnay/rust-toolchain@stable
90
- with :
91
- targets : ${{ matrix.platform.target }}
92
-
93
- - name : Install cross-compilation tool
94
- if : matrix.platform.cross
95
- run : cargo install cross
96
-
97
- - name : Build binary (native)
98
- if : " !matrix.platform.cross"
99
- run : cargo build --verbose --release --target ${{ matrix.platform.target }}
100
-
101
- - name : Build binary (cross)
102
- if : matrix.platform.cross
103
- run : cross build --verbose --release --target ${{ matrix.platform.target }}
104
-
105
- - name : Prepare release archive (Unix)
106
- if : matrix.platform.compress_format == 'tar.gz'
107
- run : |
108
- cd target/${{ matrix.platform.target }}/release
109
- tar czf ../../../${{ env.BINARY_NAME }}-${{ matrix.platform.os_name }}.${{ matrix.platform.compress_format }} ${{ env.BINARY_NAME }}${{ matrix.platform.bin_extension }}
110
- cd -
111
-
112
- - name : Prepare release archive (Windows)
113
- if : matrix.platform.compress_format == 'zip'
114
- run : |
115
- cd target/${{ matrix.platform.target }}/release
116
- 7z a ../../../${{ env.BINARY_NAME }}-${{ matrix.platform.os_name }}.${{ matrix.platform.compress_format }} ${{ env.BINARY_NAME }}${{ matrix.platform.bin_extension }}
117
- cd -
118
-
119
- - name : Generate SHA-256
120
- run : |
121
- if [ "${{ runner.os }}" = "Windows" ]; then
122
- certutil -hashfile ${{ env.BINARY_NAME }}-${{ matrix.platform.os_name }}.${{ matrix.platform.compress_format }} SHA256 > ${{ env.BINARY_NAME }}-${{ matrix.platform.os_name }}.${{ matrix.platform.compress_format }}.sha256
123
- else
124
- shasum -a 256 ${{ env.BINARY_NAME }}-${{ matrix.platform.os_name }}.${{ matrix.platform.compress_format }} > ${{ env.BINARY_NAME }}-${{ matrix.platform.os_name }}.${{ matrix.platform.compress_format }}.sha256
125
- fi
126
- shell : bash
127
-
128
- - name : Upload artifacts
129
- uses : actions/upload-artifact@v4
130
- with :
131
- name : ${{ env.BINARY_NAME }}-${{ matrix.platform.os_name }}
132
- path : |
133
- ${{ env.BINARY_NAME }}-${{ matrix.platform.os_name }}.${{ matrix.platform.compress_format }}
134
- ${{ env.BINARY_NAME }}-${{ matrix.platform.os_name }}.${{ matrix.platform.compress_format }}.sha256
135
-
136
- # Third job: Create GitHub Release
137
- create-release :
138
- name : Create GitHub Release
139
- needs : build-release
140
- runs-on : ubuntu-latest
141
- steps :
142
- - uses : actions/checkout@v4
143
-
144
- - name : Download all artifacts
145
- uses : actions/download-artifact@v4
146
- with :
147
- path : artifacts
148
-
149
- - name : Display structure of downloaded files
150
- run : ls -R
151
- working-directory : artifacts
152
-
153
- - name : Get version from tag
154
- id : get_version
155
- run : echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
156
-
157
- - name : Read CHANGELOG.md
158
- id : changelog
159
- run : |
160
- VERSION=${{ steps.get_version.outputs.VERSION }}
161
- # Extract the relevant section from CHANGELOG.md
162
- # Assuming CHANGELOG.md follows Keep a Changelog format
163
- SECTION=$(awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | head -n -1)
164
- echo "CHANGES<<EOF" >> $GITHUB_OUTPUT
165
- echo "$SECTION" >> $GITHUB_OUTPUT
166
- echo "EOF" >> $GITHUB_OUTPUT
167
-
168
- - name : Create Release
169
- uses : softprops/action-gh-release@v1
170
- with :
171
- name : Release ${{ steps.get_version.outputs.VERSION }}
172
- body : ${{ steps.changelog.outputs.CHANGES }}
173
- files : artifacts/**/*
174
- draft : false
175
- prerelease : false
176
- env :
177
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments