53
53
permissions :
54
54
contents : write
55
55
steps :
56
- - name : Calculate Release Version
57
- id : calc-version
58
- run : |
59
- if [ "${{ github.event_name }}" = "pull_request" ]; then
60
- short_sha=$(echo "${{ github.sha }}" | awk '{print substr($0,0,5)}')
61
- echo "RELEASE_VERSION=nightly-$(date '+%Y-%m-%d')-$short_sha" >> $GITHUB_OUTPUT
62
- else
63
- echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT
64
- fi
65
-
66
56
- name : Install native OpenSSL on Linux
67
57
if : runner.os == 'Linux' && !(startsWith(matrix.target, 'aarch64') || endsWith(matrix.target, 'musl'))
68
58
run : sudo apt-get install -y pkg-config libssl-dev
94
84
- name : Checkout
95
85
uses : actions/checkout@v4
96
86
87
+ - uses : actions/setup-python@v5
88
+ if : startsWith(github.ref, 'refs/tags/')
89
+ with :
90
+ python-version : ' 3.x'
91
+
92
+ - name : Increment version
93
+ if : startsWith(github.ref, 'refs/tags/')
94
+ run : python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}
95
+
97
96
- name : Setup Rust
98
97
uses : dtolnay/rust-toolchain@stable
99
98
with :
@@ -111,41 +110,19 @@ jobs:
111
110
env :
112
111
# problems with cross-compiling aarch64 linux with gnu
113
112
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER : /usr/bin/aarch64-linux-gnu-gcc
114
- run : cargo build --manifest-path cpp-linter-cli /Cargo.toml --release --bin cpp-linter-cli --target ${{ matrix.target }} ${{ steps.is-openssl-vendored.outputs.enabled }}
113
+ run : cargo build --manifest-path cpp-linter-lib /Cargo.toml --release --bin cpp-linter --target ${{ matrix.target }} ${{ steps.is-openssl-vendored.outputs.enabled }}
115
114
116
- - name : Prepare artifacts [Windows]
117
- shell : bash
118
- if : matrix.os == 'windows-latest'
119
- id : prep-artifacts-windows
120
- run : |
121
- release_dir="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}"
122
- artifact_path="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}-${{ matrix.target }}.zip"
123
- echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_OUTPUT
124
- mkdir $release_dir
125
- cp target/${{ matrix.target }}/release/cpp-linter-cli.exe $release_dir/
126
- cp LICENSE $release_dir/
127
- 7z a -tzip $artifact_path $release_dir/
128
- - name : Prepare artifacts [Unix]
129
- shell : bash
130
- id : prep-artifacts-unix
131
- if : matrix.os != 'windows-latest'
132
- run : |
133
- release_dir="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}"
134
- artifact_path="cpp-linter-cli-${{ steps.calc-version.outputs.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz"
135
- echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_OUTPUT
136
- mkdir $release_dir
137
- cp target/${{ matrix.target }}/release/cpp-linter-cli $release_dir/
138
- cp LICENSE $release_dir
139
- tar -czvf $artifact_path $release_dir/
115
+ - name : Prepare artifacts
116
+ run : mv target/${{ matrix.target }}/release/cpp-linter${{ runner.os == 'Windows' && '.exe' || '' }} ./cpp-linter-${{ matrix.target }}${{ runner.os == 'Windows' && '.exe' || '' }}
140
117
- name : Upload artifacts
141
118
uses : actions/upload-artifact@v4
142
119
with :
143
- name : ${{ steps.prep-artifacts-unix.outputs.ARTIFACT_PATH || steps.prep-artifacts-windows.outputs.ARTIFACT_PATH }}
144
- path : ${{ steps.prep-artifacts-unix.outputs.ARTIFACT_PATH || steps.prep-artifacts-windows.outputs.ARTIFACT_PATH }}
120
+ name : cpp-linter- ${{ matrix.target }}
121
+ path : cpp-linter- ${{ matrix.target }}*
145
122
if-no-files-found : error
146
123
147
124
create-release :
148
- if : startswith(github.ref, 'refs/tags ')
125
+ if : startswith(github.ref, 'refs/tagsv ')
149
126
runs-on : ubuntu-latest
150
127
needs : [create-assets]
151
128
permissions :
@@ -156,38 +133,24 @@ jobs:
156
133
persist-credentials : false
157
134
- name : Install Rust
158
135
run : rustup update stable --no-self-update
136
+ - uses : actions/setup-python@v5
137
+ with :
138
+ python-version : ' 3.x'
139
+ - name : Increment version
140
+ run : python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}
159
141
- run : cargo package
142
+ - name : Download built assets
143
+ uses : actions/download-artifact@v4
144
+ with :
145
+ pattern : cpp-linter-*
146
+ path : dist
160
147
- name : Create a Github Release
161
- if : ${{ startsWith(github.ref, 'refs/tags/v') }}
162
148
env :
163
149
GH_TOKEN : ${{ github.token }}
164
- run : gh release create ${{ github.ref_name }} --generate-notes
150
+ run : |
151
+ files=$(ls dist/cpp-linter*
152
+ gh release create ${{ github.ref_name }} --generate-notes $files
165
153
- run : cargo publish
166
154
working-directory : cpp-linter-lib
167
155
env :
168
156
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
169
-
170
- upload-assets :
171
- needs : [create-release]
172
- runs-on : ubuntu-latest
173
- strategy :
174
- matrix :
175
- target :
176
- - aarch64-unknown-linux-gnu
177
- # skip this target due to cross-compiling OpenSSL for musl C lib
178
- # - aarch64-unknown-linux-musl
179
- - x86_64-unknown-linux-gnu
180
- - x86_64-unknown-linux-musl
181
- - aarch64-apple-darwin
182
- - x86_64-apple-darwin
183
- - x86_64-pc-windows-msvc
184
- steps :
185
- - name : Download build asset
186
- uses : actions/download-artifact@v4
187
- with :
188
- name : cpp-linter-cli-${{ matrix.target }}
189
- path : dist
190
- - name : Upload release assets
191
- env :
192
- GH_TOKEN : ${{ github.token }}
193
- run : gh release upload ${{ github.ref_name }} dist/cpp-linter-cli${{ contains(matrix.target, 'windows') || '.exe' }}%#%cpp-linter-cli_${{ matrix.target }} --clobber
0 commit comments