@@ -34,118 +34,110 @@ jobs:
34
34
include :
35
35
- target : aarch64-unknown-linux-gnu
36
36
os : ubuntu-latest
37
- # # I GIVE UP! For this target, OpenSSL needs to be cross compiled
38
- # # which is driven by openssl-sys crate's custom build script...
39
- # # Linux users with aarch64 (aka ARM64) using musl C lib can go fish (or build from source).
40
- # - target: aarch64-unknown-linux-musl
41
- # os: ubuntu-latest
37
+ vendered : true
38
+ cross : true
39
+ - target : aarch64-unknown-linux-musl
40
+ os : ubuntu-latest
41
+ vendered : true
42
+ cross : true
42
43
- target : x86_64-unknown-linux-gnu
43
44
os : ubuntu-latest
45
+ vendered : false
46
+ cross : false
44
47
- target : x86_64-unknown-linux-musl
45
48
os : ubuntu-latest
49
+ vendered : true
50
+ cross : true
51
+ - target : arm-unknown-linux-gnueabi
52
+ os : ubuntu-latest
53
+ vendered : true
54
+ cross : true
55
+ - target : arm-unknown-linux-gnueabihf
56
+ os : ubuntu-latest
57
+ vendered : true
58
+ cross : true
59
+ - target : armv7-unknown-linux-gnueabihf
60
+ os : ubuntu-latest
61
+ vendered : true
62
+ cross : true
63
+ - target : powerpc-unknown-linux-gnu
64
+ os : ubuntu-latest
65
+ vendered : true
66
+ cross : true
67
+ - target : powerpc64-unknown-linux-gnu
68
+ os : ubuntu-latest
69
+ vendered : true
70
+ cross : true
71
+ - target : powerpc64le-unknown-linux-gnu
72
+ os : ubuntu-latest
73
+ vendered : true
74
+ cross : true
75
+ - target : s390x-unknown-linux-gnu
76
+ os : ubuntu-latest
77
+ vendered : true
78
+ cross : true
46
79
- target : aarch64-apple-darwin
47
80
os : macos-latest
81
+ vendered : true
82
+ cross : false
48
83
- target : x86_64-apple-darwin
49
84
os : macos-latest
85
+ vendered : true
86
+ cross : false
50
87
- target : x86_64-pc-windows-msvc
51
88
os : windows-latest
89
+ vendered : false
90
+ cross : false
91
+ - target : aarch64-pc-windows-msvc
92
+ os : windows-latest
93
+ vendered : false
94
+ cross : false
52
95
runs-on : ${{ matrix.os }}
53
96
permissions :
54
97
contents : write
55
98
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
- - name : Install native OpenSSL on Linux
67
- if : runner.os == 'Linux' && !(startsWith(matrix.target, 'aarch64') || endsWith(matrix.target, 'musl'))
68
- run : sudo apt-get install -y pkg-config libssl-dev
69
- - name : Install GCC for aarch64 (for cross-compiling openssl)
70
- if : runner.os == 'Linux' && startsWith(matrix.target, 'aarch64')
71
- run : |
72
- sudo apt-get update
73
- sudo apt-get install gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
74
- if [[ "${{matrix.target}}" == *musl ]]; then
75
- sudo apt-get install musl-dev musl-tools
76
- fi
77
- - name : Install musl-gcc (for compiling OpenSSL)
78
- if : matrix.target == 'x86_64-unknown-linux-musl'
79
- run : sudo apt-get install musl-tools
80
-
81
- - name : Calculate openssl-vendored
82
- shell : bash
83
- id : is-openssl-vendored
84
- run : |
85
- case "${{ matrix.target }}" in
86
- "aarch64-apple-darwin" | "x86_64-apple-darwin" | "aarch64-unknown-linux-gnu" | "aarch64-unknown-linux-musl" | "x86_64-unknown-linux-musl")
87
- echo "enabled=--features openssl-vendored" >> $GITHUB_OUTPUT
88
- ;;
89
- *)
90
- echo "enabled=" >> $GITHUB_OUTPUT
91
- ;;
92
- esac
93
-
94
99
- name : Checkout
95
100
uses : actions/checkout@v4
96
101
102
+ - uses : actions/setup-python@v5
103
+ if : startsWith(github.ref, 'refs/tags/')
104
+ with :
105
+ python-version : ' 3.x'
106
+
107
+ - name : Increment version
108
+ if : startsWith(github.ref, 'refs/tags/')
109
+ run : python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}
110
+
97
111
- name : Setup Rust
98
112
uses : dtolnay/rust-toolchain@stable
99
113
with :
100
114
target : ${{ matrix.target }}
101
115
102
- # problems with cross-compiling linux with musl
103
- - run : echo "RUSTFLAGS=-D warnings -C target-feature=+crt-static -C link-self-contained=yes" >> "${GITHUB_ENV}"
104
- if : contains(matrix.target, '-linux-musl')
105
- - run : |
106
- echo "CC=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
107
- echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
108
- if: matrix.target == 'aarch64-unknown-linux-musl'
116
+ - name : Install cross (cargo cross compiler)
117
+ if : matrix.cross
118
+ uses : taiki-e/install-action@v2
119
+ with :
120
+ tool : cross
121
+
122
+ - name : Build (native)
123
+ if : ${{ !matrix.cross }}
124
+ run : cargo build --manifest-path cpp-linter-lib/Cargo.toml --release --bin cpp-linter --target ${{ matrix.target }} ${{ matrix.vendered && '--features openssl-vendored' || '' }}
109
125
110
- - name : Build
111
- env :
112
- # problems with cross-compiling aarch64 linux with gnu
113
- 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 }}
126
+ - name : Build (cross)
127
+ if : matrix.cross
128
+ run : cross build --manifest-path cpp-linter-lib/Cargo.toml --release --bin cpp-linter --target ${{ matrix.target }} ${{ matrix.vendered && '--features openssl-vendored' || '' }}
115
129
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/
130
+ - name : Prepare artifacts
131
+ run : mv target/${{ matrix.target }}/release/cpp-linter${{ runner.os == 'Windows' && '.exe' || '' }} ./cpp-linter-${{ matrix.target }}${{ runner.os == 'Windows' && '.exe' || '' }}
140
132
- name : Upload artifacts
141
133
uses : actions/upload-artifact@v4
142
134
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 }}
135
+ name : cpp-linter- ${{ matrix.target }}
136
+ path : cpp-linter- ${{ matrix.target }}*
145
137
if-no-files-found : error
146
138
147
139
create-release :
148
- if : startswith(github.ref, 'refs/tags ')
140
+ if : startswith(github.ref, 'refs/tagsv ')
149
141
runs-on : ubuntu-latest
150
142
needs : [create-assets]
151
143
permissions :
@@ -156,38 +148,24 @@ jobs:
156
148
persist-credentials : false
157
149
- name : Install Rust
158
150
run : rustup update stable --no-self-update
151
+ - uses : actions/setup-python@v5
152
+ with :
153
+ python-version : ' 3.x'
154
+ - name : Increment version
155
+ run : python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}
159
156
- run : cargo package
157
+ - name : Download built assets
158
+ uses : actions/download-artifact@v4
159
+ with :
160
+ pattern : cpp-linter-*
161
+ path : dist
160
162
- name : Create a Github Release
161
- if : ${{ startsWith(github.ref, 'refs/tags/v') }}
162
163
env :
163
164
GH_TOKEN : ${{ github.token }}
164
- run : gh release create ${{ github.ref_name }} --generate-notes
165
+ run : |
166
+ files=$(ls dist/cpp-linter*
167
+ gh release create ${{ github.ref_name }} --generate-notes $files
165
168
- run : cargo publish
166
169
working-directory : cpp-linter-lib
167
170
env :
168
171
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