Refactor creating deb package into separate script
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Which I think is cleaner than having it inline in the github actions yaml
authored by Thayne McCombs · committed by Thayne McCombs · parent 9f0fea6 · Browse files · 2 files·+133 added−107 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+133 added−107 removed
- other:+133 added−107 removed
Provenance
- Commit
55d2e78- Tree
37a8ff9- Author
Thayne McCombs <astrothayne@gmail.com>- Committer
Thayne McCombs <astrothayne@gmail.com>- Parent
9f0fea6
2 files changed+133 added−107 removed
modified:.github/workflows/CICD.yml+5 added-107 removed
214 unmodified lines215 - name: Create Debian package216 id: debian-package217 shell: bash218 if: startsWith(matrix.job.os, 'ubuntu')219- run: |220- COPYRIGHT_YEARS="2018 - "$(date "+%Y")221- DPKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/debian-package"222- DPKG_DIR="${DPKG_STAGING}/dpkg"223- mkdir -p "${DPKG_DIR}"219+ run: bash scripts/create-deb.sh220+ env:221+ TARGET: ${{ matrix.job.target }}222+ DPKG_VERSION: ${{ needs.crate_metadata.version }}223+ BIN_PATH: ${{ steps.bin.outputs.BIN_PATH }}224 225- DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}226- DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }}-musl227- case ${{ matrix.job.target }} in *-musl*) DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-musl ; DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }} ;; esac;228- DPKG_VERSION=${{ needs.crate_metadata.outputs.version }}229-230- unset DPKG_ARCH231- case ${{ matrix.job.target }} in232- aarch64-*-linux-*) DPKG_ARCH=arm64 ;;233- arm-*-linux-*hf) DPKG_ARCH=armhf ;;234- i686-*-linux-*) DPKG_ARCH=i686 ;;235- x86_64-*-linux-*) DPKG_ARCH=amd64 ;;236- *) DPKG_ARCH=notset ;;237- esac;238-239- DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb"240- echo "DPKG_NAME=${DPKG_NAME}" >> $GITHUB_OUTPUT241-242- # Binary243- install -Dm755 "${{ steps.bin.outputs.BIN_PATH }}" "${DPKG_DIR}/usr/bin/${{ steps.bin.outputs.BIN_NAME }}"244-245- # Man page246- install -Dm644 'doc/${{ needs.crate_metadata.outputs.name }}.1' "${DPKG_DIR}/usr/share/man/man1/${{ needs.crate_metadata.outputs.name }}.1"247- gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ needs.crate_metadata.outputs.name }}.1"248-249- # Autocompletion files250- install -Dm644 'autocomplete/fd.bash' "${DPKG_DIR}/usr/share/bash-completion/completions/${{ needs.crate_metadata.outputs.name }}"251- install -Dm644 'autocomplete/fd.fish' "${DPKG_DIR}/usr/share/fish/vendor_completions.d/${{ needs.crate_metadata.outputs.name }}.fish"252- install -Dm644 'autocomplete/_fd' "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ needs.crate_metadata.outputs.name }}"253-254- # README and LICENSE255- install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/README.md"256- install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-MIT"257- install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-APACHE"258- install -Dm644 "CHANGELOG.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog"259- gzip -n --best "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog"260-261- cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" <<EOF262- Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/263- Upstream-Name: ${{ needs.crate_metadata.outputs.name }}264- Source: ${{ needs.crate_metadata.outputs.homepage }}265-266- Files: *267- Copyright: ${{ needs.crate_metadata.outputs.maintainer }}268- Copyright: $COPYRIGHT_YEARS ${{ needs.crate_metadata.outputs.maintainer }}269- License: Apache-2.0 or MIT270-271- License: Apache-2.0272- On Debian systems, the complete text of the Apache-2.0 can be found in the273- file /usr/share/common-licenses/Apache-2.0.274-275- License: MIT276- Permission is hereby granted, free of charge, to any277- person obtaining a copy of this software and associated278- documentation files (the "Software"), to deal in the279- Software without restriction, including without280- limitation the rights to use, copy, modify, merge,281- publish, distribute, sublicense, and/or sell copies of282- the Software, and to permit persons to whom the Software283- is furnished to do so, subject to the following284- conditions:285- .286- The above copyright notice and this permission notice287- shall be included in all copies or substantial portions288- of the Software.289- .290- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF291- ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED292- TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A293- PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT294- SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY295- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION296- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR297- IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER298- DEALINGS IN THE SOFTWARE.299- EOF300- chmod 644 "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright"301-302- # control file303- mkdir -p "${DPKG_DIR}/DEBIAN"304- cat > "${DPKG_DIR}/DEBIAN/control" <<EOF305- Package: ${DPKG_BASENAME}306- Version: ${DPKG_VERSION}307- Section: utils308- Priority: optional309- Maintainer: ${{ needs.crate_metadata.outputs.maintainer }}310- Homepage: ${{ needs.crate_metadata.outputs.homepage }}311- Architecture: ${DPKG_ARCH}312- Provides: ${{ needs.crate_metadata.outputs.name }}313- Conflicts: ${DPKG_CONFLICTS}314- Description: simple, fast and user-friendly alternative to find315- fd is a program to find entries in your filesystem.316- It is a simple, fast and user-friendly alternative to find.317- While it does not aim to support all of finds powerful functionality, it provides318- sensible (opinionated) defaults for a majority of use cases.319- EOF320-321- DPKG_PATH="${DPKG_STAGING}/${DPKG_NAME}"322- echo "DPKG_PATH=${DPKG_PATH}" >> $GITHUB_OUTPUT323-324- # build dpkg325- fakeroot dpkg-deb --build "${DPKG_DIR}" "${DPKG_PATH}"326-225 - name: "Artifact upload: tarball"226 uses: actions/upload-artifact@master227 with:228 name: ${{ steps.package.outputs.PKG_NAME }}37 unmodified linesadded:scripts/create-deb.sh+128 added
1+#!/bin/bash2+COPYRIGHT_YEARS="2018 - "$(date "+%Y")3+MAINTAINER="David Peter <mail@david-peter.de>"4+REPO="https://github.com/sharkdp/fd"5+DPKG_STAGING="${CICD_INTERMEDIATES_DIR:-.}/debian-package"6+DPKG_DIR="${DPKG_STAGING}/dpkg"7+mkdir -p "${DPKG_DIR}"8+9+if [[ -z "$TARGET" ]]; then10+ TARGET="$(rustc -vV | sed -n 's|host: \(.*\)|\1|p')"11+fi12+13+case "$TARGET" in14+ *-musl*)15+ DPKG_BASENAME=fd-musl16+ DPKG_CONFLICTS=fd17+ ;;18+ *)19+ DPKG_BASENAME=fd20+ DPKG_CONFLICTS=fd-musl21+ ;;22+esac23+24+if [[ -z "$DPKG_VERSION" ]]; then25+ DPKG_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r .packages[0].version)26+fi27+28+unset DPKG_ARCH29+case "${TARGET}" in30+ aarch64-*-linux-*) DPKG_ARCH=arm64 ;;31+ arm-*-linux-*hf) DPKG_ARCH=armhf ;;32+ i686-*-linux-*) DPKG_ARCH=i686 ;;33+ x86_64-*-linux-*) DPKG_ARCH=amd64 ;;34+ *) DPKG_ARCH=notset ;;35+esac;36+37+DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb"38+39+BIN_PATH=${BIN_PATH:-target/${TARGET}/release/fd}40+41+# Binary42+install -Dm755 "${BIN_PATH}" "${DPKG_DIR}/usr/bin/fd"43+44+# Man page45+install -Dm644 'doc/fd.1' "${DPKG_DIR}/usr/share/man/man1/fd.1"46+gzip -n --best "${DPKG_DIR}/usr/share/man/man1/fd.1"47+48+# Autocompletion files49+install -Dm644 'autocomplete/fd.bash' "${DPKG_DIR}/usr/share/bash-completion/completions/fd"50+install -Dm644 'autocomplete/fd.fish' "${DPKG_DIR}/usr/share/fish/vendor_completions.d/fd.fish"51+install -Dm644 'autocomplete/_fd' "${DPKG_DIR}/usr/share/zsh/vendor-completions/_fd"52+53+# README and LICENSE54+install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/README.md"55+install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-MIT"56+install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-APACHE"57+install -Dm644 "CHANGELOG.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog"58+gzip -n --best "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog"59+60+cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" <<EOF61+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/62+Upstream-Name: fd63+Source: ${REPO}64+65+Files: *66+Copyright: ${MAINTAINER}67+Copyright: $COPYRIGHT_YEARS ${MAINTAINER}68+License: Apache-2.0 or MIT69+70+License: Apache-2.071+ On Debian systems, the complete text of the Apache-2.0 can be found in the72+ file /usr/share/common-licenses/Apache-2.0.73+74+License: MIT75+ Permission is hereby granted, free of charge, to any76+ person obtaining a copy of this software and associated77+ documentation files (the "Software"), to deal in the78+ Software without restriction, including without79+ limitation the rights to use, copy, modify, merge,80+ publish, distribute, sublicense, and/or sell copies of81+ the Software, and to permit persons to whom the Software82+ is furnished to do so, subject to the following83+ conditions:84+ .85+ The above copyright notice and this permission notice86+ shall be included in all copies or substantial portions87+ of the Software.88+ .89+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF90+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED91+ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A92+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT93+ SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY94+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION95+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR96+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER97+ DEALINGS IN THE SOFTWARE.98+EOF99+ chmod 644 "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright"100+101+ # control file102+ mkdir -p "${DPKG_DIR}/DEBIAN"103+ cat > "${DPKG_DIR}/DEBIAN/control" <<EOF104+Package: ${DPKG_BASENAME}105+Version: ${DPKG_VERSION}106+Section: utils107+Priority: optional108+Maintainer: ${MAINTAINER}109+Homepage: ${REPO}110+Architecture: ${DPKG_ARCH}111+Provides: fd112+Conflicts: ${DPKG_CONFLICTS}113+Description: simple, fast and user-friendly alternative to find114+ fd is a program to find entries in your filesystem.115+ It is a simple, fast and user-friendly alternative to find.116+ While it does not aim to support all of finds powerful functionality, it provides117+ sensible (opinionated) defaults for a majority of use cases.118+EOF119+120+DPKG_PATH="${DPKG_STAGING}/${DPKG_NAME}"121+122+if [[ -n $GITHUB_OUTPUT ]]; then123+ echo "DPKG_NAME=${DPKG_NAME}" >> "$GITHUB_OUTPUT"124+ echo "DPKG_PATH=${DPKG_PATH}" >> "$GITHUB_OUTPUT"125+fi126+127+# build dpkg128+fakeroot dpkg-deb --build "${DPKG_DIR}" "${DPKG_PATH}"