@@ -4,13 +4,12 @@ name: CICD
4
4
# spell-checker:ignore (env/flags) Ccodegen Coverflow RUSTFLAGS
5
5
# spell-checker:ignore (jargon) SHAs deps softprops toolchain
6
6
# spell-checker:ignore (names) CodeCOV MacOS MinGW Peltoche rivy
7
- # spell-checker:ignore (shell/tools) choco clippy dmake esac fakeroot gmake grcov halium lcov libssl mkdir popd printf pushd rustc rustfmt rustup shopt xargs
8
- # spell-checker:ignore (misc) alnum gnueabihf issuecomment maint nullglob onexitbegin onexitend uutils
9
-
7
+ # spell-checker:ignore (shell/tools) choco clippy dmake dpkg esac fakeroot gmake grcov halium lcov libssl mkdir popd printf pushd rustc rustfmt rustup shopt xargs
8
+ # spell-checker:ignore (misc) aarch alnum armhf coreutils gnueabihf issuecomment maint nullglob onexitbegin onexitend uutils
10
9
11
10
env :
12
- PROJECT_NAME : uutils
13
- PROJECT_DESC : " 'Universal' (cross-platform) CLI utilities"
11
+ PROJECT_NAME : coreutils
12
+ PROJECT_DESC : " Core universal (cross-platform) utilities"
14
13
PROJECT_AUTH : " uutils"
15
14
RUST_MIN_SRV : " 1.31.0" # # v1.31.0 == "Rust 2018" (2018-12-06)
16
15
RUST_COV_SRV : " 2020-04-29" # # (~v1.45.0) supported rust version for code coverage; (date required/used by 'coverage') ## !maint: refactor when code coverage support is included in the stable channel
35
34
shell : bash
36
35
run : |
37
36
## VARs setup
38
- # #maint: [rivy; 2020-02-08] 'windows-latest' `cargo fmt` is bugged for this project (see reasons @ GH:rust-lang/rustfmt #3324, #3590, #3688 ; waiting for repair)
39
- JOB_DO_FORMAT_TESTING="true"
40
- case '${{ matrix.job.os }}' in windows-latest) unset JOB_DO_FORMAT_TESTING ;; esac;
41
- echo set-output name=JOB_DO_FORMAT_TESTING::${JOB_DO_FORMAT_TESTING:-<empty>/false}
42
- echo ::set-output name=JOB_DO_FORMAT_TESTING::${JOB_DO_FORMAT_TESTING}
43
37
# target-specific options
44
38
# * CARGO_FEATURES_OPTION
45
39
CARGO_FEATURES_OPTION='' ;
@@ -54,14 +48,12 @@ jobs:
54
48
profile : minimal # minimal component installation (ie, no documentation)
55
49
components : rustfmt, clippy
56
50
- name : " `fmt` testing"
57
- if : steps.vars.outputs.JOB_DO_FORMAT_TESTING
58
51
shell : bash
59
52
run : |
60
53
# `fmt` testing
61
54
# * convert any warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
62
55
S=$(cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::warning file=\1,line=\2::WARNING: \`cargo fmt\`: style violation/p" ; }
63
56
- name : " `fmt` testing of tests"
64
- if : steps.vars.outputs.JOB_DO_FORMAT_TESTING
65
57
shell : bash
66
58
run : |
67
59
# `fmt` testing of tests
@@ -130,7 +122,10 @@ jobs:
130
122
job :
131
123
# { os, target, cargo-options, features, use-cross, toolchain }
132
124
- { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , features: feat_os_unix_gnueabihf , use-cross: use-cross }
125
+ - { os: ubuntu-latest , target: aarch64-unknown-linux-gnu , features: feat_os_unix_gnueabihf , use-cross: use-cross }
133
126
- { os: ubuntu-16.04 , target: x86_64-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
127
+ # - { os: ubuntu-18.04 , target: i586-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross } ## note: older windows platform; not required, dev-FYI only
128
+ # - { os: ubuntu-18.04 , target: i586-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross } ## note: older windows platform; not required, dev-FYI only
134
129
- { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
135
130
- { os: ubuntu-18.04 , target: i686-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
136
131
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
@@ -148,6 +143,7 @@ jobs:
148
143
## install/setup prerequisites
149
144
case '${{ matrix.job.target }}' in
150
145
arm-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
146
+ aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
151
147
esac
152
148
- name : Initialize workflow variables
153
149
id : vars
@@ -186,7 +182,14 @@ jobs:
186
182
echo ::set-output name=REF_TAG::${REF_TAG}
187
183
echo ::set-output name=REF_SHAS::${REF_SHAS}
188
184
# parse target
189
- unset TARGET_ARCH ; case '${{ matrix.job.target }}' in arm-unknown-linux-gnueabihf) TARGET_ARCH=arm ;; i686-*) TARGET_ARCH=i686 ;; x86_64-*) TARGET_ARCH=x86_64 ;; esac;
185
+ unset TARGET_ARCH
186
+ case '${{ matrix.job.target }}' in
187
+ aarch64-*) TARGET_ARCH=arm64 ;;
188
+ arm-*-*hf) TARGET_ARCH=armhf ;;
189
+ i586-*) TARGET_ARCH=i586 ;;
190
+ i686-*) TARGET_ARCH=i686 ;;
191
+ x86_64-*) TARGET_ARCH=x86_64 ;;
192
+ esac;
190
193
echo set-output name=TARGET_ARCH::${TARGET_ARCH}
191
194
echo ::set-output name=TARGET_ARCH::${TARGET_ARCH}
192
195
unset TARGET_OS ; case '${{ matrix.job.target }}' in *-linux-*) TARGET_OS=linux ;; *-apple-*) TARGET_OS=macos ;; *-windows-*) TARGET_OS=windows ;; esac;
@@ -203,9 +206,34 @@ jobs:
203
206
echo ::set-output name=PKG_BASENAME::${PKG_BASENAME}
204
207
echo ::set-output name=PKG_NAME::${PKG_NAME}
205
208
# deployable tag? (ie, leading "vM" or "M"; M == version number)
206
- unset DEPLOYABLE ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOYABLE='true' ; fi
207
- echo set-output name=DEPLOYABLE::${DEPLOYABLE:-<empty>/false}
208
- echo ::set-output name=DEPLOYABLE::${DEPLOYABLE}
209
+ unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
210
+ echo set-output name=DEPLOY::${DEPLOY:-<empty>/false}
211
+ echo ::set-output name=DEPLOY::${DEPLOY}
212
+ # DPKG architecture?
213
+ unset DPKG_ARCH
214
+ case ${{ matrix.job.target }} in
215
+ x86_64-*-linux-*) DPKG_ARCH=amd64 ;;
216
+ *-linux-*) DPKG_ARCH=${TARGET_ARCH} ;;
217
+ esac
218
+ echo set-output name=DPKG_ARCH::${DPKG_ARCH}
219
+ echo ::set-output name=DPKG_ARCH::${DPKG_ARCH}
220
+ # DPKG version?
221
+ unset DPKG_VERSION ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DPKG_VERSION=${REF_TAG/#[vV]/} ; fi
222
+ echo set-output name=DPKG_VERSION::${DPKG_VERSION}
223
+ echo ::set-output name=DPKG_VERSION::${DPKG_VERSION}
224
+ # DPKG base name/conflicts?
225
+ DPKG_BASENAME=${PROJECT_NAME}
226
+ DPKG_CONFLICTS=${PROJECT_NAME}-musl
227
+ case ${{ matrix.job.target }} in *-musl) DPKG_BASENAME=${PROJECT_NAME}-musl ; DPKG_CONFLICTS=${PROJECT_NAME} ;; esac;
228
+ echo set-output name=DPKG_BASENAME::${DPKG_BASENAME}
229
+ echo set-output name=DPKG_CONFLICTS::${DPKG_CONFLICTS}
230
+ echo ::set-output name=DPKG_BASENAME::${DPKG_BASENAME}
231
+ echo ::set-output name=DPKG_CONFLICTS::${DPKG_CONFLICTS}
232
+ # DPKG name
233
+ unset DPKG_NAME;
234
+ if [[ -n $DPKG_ARCH && -n $DPKG_VERSION ]]; then DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb" ; fi
235
+ echo set-output name=DPKG_NAME::${DPKG_NAME}
236
+ echo ::set-output name=DPKG_NAME::${DPKG_NAME}
209
237
# target-specific options
210
238
# * CARGO_FEATURES_OPTION
211
239
CARGO_FEATURES_OPTION='' ;
@@ -216,18 +244,17 @@ jobs:
216
244
CARGO_USE_CROSS='true' ; case '${{ matrix.job.use-cross }}' in ''|0|f|false|n|no) unset CARGO_USE_CROSS ;; esac;
217
245
echo set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS:-<empty>/false}
218
246
echo ::set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS}
219
- # # * `arm` cannot be tested on ubuntu-* hosts (b/c testing is currently primarily done via comparison of target outputs with built-in outputs and the `arm` target is not executable on the host)
220
- JOB_DO_TESTING="true"
221
- case '${{ matrix.job.target }}' in arm-*) unset JOB_DO_TESTING ;; esac;
222
- echo set-output name=JOB_DO_TESTING::${JOB_DO_TESTING:-<empty>/false}
223
- echo ::set-output name=JOB_DO_TESTING::${JOB_DO_TESTING}
224
- # # * test only binary for arm-type targets
225
- unset CARGO_TEST_OPTIONS
226
- unset CARGO_TEST_OPTIONS ; case '${{ matrix.job.target }}' in arm-*) CARGO_TEST_OPTIONS="--bin ${PROJECT_NAME}" ;; esac;
247
+ # * test only library and/or binaries for arm-type targets
248
+ unset CARGO_TEST_OPTIONS ; case '${{ matrix.job.target }}' in aarch64-* | arm-*) CARGO_TEST_OPTIONS="--bins" ;; esac;
227
249
echo set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
228
250
echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
229
- # * strip executable?
230
- STRIP="strip" ; case '${{ matrix.job.target }}' in arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; *-pc-windows-msvc) STRIP="" ;; esac;
251
+ # * executable for `strip`?
252
+ STRIP="strip"
253
+ case ${{ matrix.job.target }} in
254
+ aarch64-*-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;;
255
+ arm-*-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;;
256
+ *-pc-windows-msvc) STRIP="" ;;
257
+ esac;
231
258
echo set-output name=STRIP::${STRIP:-<empty>/false}
232
259
echo ::set-output name=STRIP::${STRIP}
233
260
- name : Create all needed build/work directories
@@ -236,6 +263,7 @@ jobs:
236
263
## create build/work space
237
264
mkdir -p '${{ steps.vars.outputs.STAGING }}'
238
265
mkdir -p '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}'
266
+ mkdir -p '${{ steps.vars.outputs.STAGING }}/dpkg'
239
267
- name : rust toolchain ~ install
240
268
uses : actions-rs/toolchain@v1
241
269
with :
@@ -307,12 +335,28 @@ jobs:
307
335
*) tar czf '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* ;;
308
336
esac
309
337
popd >/dev/null
338
+ # dpkg
339
+ if [ -n "${{ steps.vars.outputs.DPKG_NAME }}" ]; then
340
+ DPKG_DIR="${{ steps.vars.outputs.STAGING }}/dpkg"
341
+ # binary
342
+ install -Dm755 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}"
343
+ if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}" ; fi
344
+ # README and LICENSE
345
+ (shopt -s nullglob; for f in [R]"EADME"{,.*}; do install -Dm644 "$f" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/$f" ; done)
346
+ (shopt -s nullglob; for f in [L]"ICENSE"{-*,}{,.*}; do install -Dm644 "$f" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/$f" ; done)
347
+ # control file
348
+ mkdir -p "${DPKG_DIR}/DEBIAN"
349
+ printf "Package: ${{ steps.vars.outputs.DPKG_BASENAME }}\nVersion: ${{ steps.vars.outputs.DPKG_VERSION }}\nSection: utils\nPriority: optional\nMaintainer: ${{ env.PROJECT_AUTH }}\nArchitecture: ${{ steps.vars.outputs.DPKG_ARCH }}\nProvides: ${{ env.PROJECT_NAME }}\nConflicts: ${{ steps.vars.outputs.DPKG_CONFLICTS }}\nDescription: ${{ env.PROJECT_DESC }}\n" > "${DPKG_DIR}/DEBIAN/control"
350
+ # build dpkg
351
+ fakeroot dpkg-deb --build "${DPKG_DIR}" "${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}"
352
+ fi
310
353
- name : Publish
311
354
uses : softprops/action-gh-release@v1
312
- if : steps.vars.outputs.DEPLOYABLE
355
+ if : steps.vars.outputs.DEPLOY
313
356
with :
314
357
files : |
315
358
${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
359
+ ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}
316
360
env :
317
361
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
318
362
0 commit comments