watchexec/.github/workflows/release-cli.yml

356 lines
10 KiB
YAML
Raw Normal View History

name: CLI Release
on:
workflow_call:
workflow_dispatch:
push:
tags:
2022-09-07 01:24:53 +02:00
- "v*.*.*"
2022-09-07 04:15:38 +02:00
env:
CARGO_TERM_COLOR: always
CARGO_UNSTABLE_SPARSE_REGISTRY: "true"
jobs:
info:
name: Gather info
runs-on: ubuntu-latest
outputs:
cli_version: ${{ steps.version.outputs.cli_version }}
2023-12-20 02:06:41 +01:00
release_notes: ${{ fromJSON(steps.notes.outputs.notes_json || 'null') }}
announce: ${{ steps.announce.outputs.announce || '' }}
steps:
- uses: actions/checkout@v4
- name: Extract version
id: version
shell: bash
run: |
set -euxo pipefail
version=$(grep -m1 -F 'version =' crates/cli/Cargo.toml | cut -d\" -f2)
if [[ -z "$version" ]]; then
echo "Error: no version :("
exit 1
fi
2023-03-22 05:23:48 +01:00
echo "cli_version=$version" >> $GITHUB_OUTPUT
2022-06-29 04:21:57 +02:00
- name: Extract release notes
2023-12-20 02:06:41 +01:00
if: github.event.head_commit.message
2022-06-29 04:21:57 +02:00
id: notes
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
release_commit: ${{ github.event.head_commit.message }}
run: |
set -x
2023-12-20 02:06:41 +01:00
set +eo pipefail
if [[ -z "$release_commit" ]]; then
echo "notes_json=null" >> $GITHUB_OUTPUT
exit
fi
release_pr=$(head -n1 <<< "$release_commit" | grep -oP '(?<=[(]#)\d+(?=[)])')
2022-06-29 04:21:57 +02:00
if [[ -z "$release_pr" ]]; then
2023-03-22 05:23:48 +01:00
echo "notes_json=null" >> $GITHUB_OUTPUT
2022-06-29 04:21:57 +02:00
exit
fi
gh \
2022-06-29 04:21:57 +02:00
pr --repo "$GITHUB_REPO" \
view "$release_pr" \
--json body \
2023-03-22 05:23:48 +01:00
--jq '"notes_json=\((.body | split("### Release notes")[1] // "") | tojson)"' \
>> $GITHUB_OUTPUT
2022-06-29 04:21:57 +02:00
- name: Make a new announcement post
id: announce
if: endsWith(steps.version.outputs.cli_version, '.0')
2023-03-22 05:23:48 +01:00
run: echo "announce=Announcements" >> $GITHUB_OUTPUT
2022-06-29 04:21:57 +02:00
build:
strategy:
matrix:
name:
- linux-amd64-gnu
- linux-amd64-musl
- linux-i686-musl
- linux-armhf-gnu
- linux-arm64-gnu
2021-09-05 22:42:20 +02:00
- linux-arm64-musl
- linux-s390x-gnu
- linux-ppc64le-gnu
- mac-x86-64
- mac-arm64
- windows-x86-64
include:
- name: linux-amd64-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
cross: false
experimental: false
- name: linux-amd64-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
cross: true
experimental: false
- name: linux-i686-musl
os: ubuntu-latest
target: i686-unknown-linux-musl
cross: true
experimental: true
- name: linux-armhf-gnu
os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
cross: true
experimental: false
- name: linux-arm64-gnu
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
cross: true
experimental: false
2021-09-05 22:42:20 +02:00
- name: linux-arm64-musl
os: ubuntu-latest
target: aarch64-unknown-linux-musl
cross: true
experimental: true
- name: linux-s390x-gnu
os: ubuntu-latest
target: s390x-unknown-linux-gnu
cross: true
experimental: false
- name: linux-ppc64le-gnu
os: ubuntu-latest
target: powerpc64le-unknown-linux-gnu
cross: true
experimental: false
- name: mac-x86-64
os: macos-latest
target: x86_64-apple-darwin
cross: false
experimental: false
- name: mac-arm64
2021-04-30 16:25:10 +02:00
os: macos-11.0
target: aarch64-apple-darwin
cross: true
experimental: true
- name: windows-x86-64
os: windows-latest
target: x86_64-pc-windows-msvc
cross: false
experimental: false
#- name: windows-arm64
# os: windows-latest
# target: aarch64-pc-windows-msvc
# cross: true
# experimental: true
2021-04-30 16:26:33 +02:00
name: Binaries for ${{ matrix.name }}
needs: info
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
env:
version: ${{ needs.info.outputs.cli_version }}
dst: watchexec-${{ needs.info.outputs.cli_version }}-${{ matrix.target }}
steps:
- uses: actions/checkout@v4
2022-09-07 05:41:34 +02:00
# https://github.com/actions/cache/issues/752
- if: ${{ runner.os == 'Windows' }}
name: Use GNU tar
shell: cmd
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
2022-09-07 04:15:38 +02:00
- name: Configure caching
uses: actions/cache@v3
with:
2022-09-07 04:15:38 +02:00
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.target }}-
${{ runner.os }}-cargo-
2023-12-20 02:06:41 +01:00
- run: sudo apt update
2023-12-19 23:34:29 +01:00
if: startsWith(matrix.os, 'ubuntu-')
2022-01-23 01:44:09 +01:00
- name: Add musl tools
run: sudo apt install -y musl musl-dev musl-tools
if: endsWith(matrix.target, '-musl')
- name: Add aarch-gnu tools
run: sudo apt install -y gcc-aarch64-linux-gnu
if: startsWith(matrix.target, 'aarch64-unknown-linux')
- name: Add arm7hf-gnu tools
run: sudo apt install -y gcc-arm-linux-gnueabihf
if: startsWith(matrix.target, 'armv7-unknown-linux-gnueabihf')
- name: Add s390x-gnu tools
run: sudo apt install -y gcc-s390x-linux-gnu
if: startsWith(matrix.target, 's390x-unknown-linux-gnu')
- name: Add ppc64le-gnu tools
run: sudo apt install -y gcc-powerpc64le-linux-gnu
if: startsWith(matrix.target, 'powerpc64le-unknown-linux-gnu')
2022-01-23 01:44:09 +01:00
- name: Install cargo-deb
2021-07-21 16:14:03 +02:00
if: startsWith(matrix.name, 'linux-')
uses: taiki-e/install-action@v2
2022-03-18 02:12:23 +01:00
with:
2022-09-07 04:15:38 +02:00
tool: cargo-deb
2022-03-18 02:12:23 +01:00
2022-01-18 12:20:23 +01:00
- name: Install cargo-generate-rpm
if: startsWith(matrix.name, 'linux-')
uses: taiki-e/install-action@v2
2022-03-18 02:12:23 +01:00
with:
2022-09-07 04:15:38 +02:00
tool: cargo-generate-rpm
2022-09-07 04:15:38 +02:00
- name: Configure toolchain
run: |
rustup toolchain install --profile minimal --no-self-update stable
rustup default stable
rustup target add ${{ matrix.target }}
2022-09-07 04:15:38 +02:00
- name: Install cross
if: matrix.cross
uses: taiki-e/install-action@v2
with:
2022-09-07 04:15:38 +02:00
tool: cross
- name: Build (cargo)
if: "!matrix.cross"
run: cargo build --package watchexec-cli --release --locked --target ${{ matrix.target }}
- name: Build (cross)
if: matrix.cross
run: cross build --package watchexec-cli --release --locked --target ${{ matrix.target }}
- name: Make manpage
run: cargo run -p watchexec-cli -- --manual > doc/watchexec.1
- name: Make completions
run: bin/completions
- name: Package
shell: bash
run: |
set -euxo pipefail
ext=""
[[ "${{ matrix.name }}" == windows-* ]] && ext=".exe"
bin="target/${{ matrix.target }}/release/watchexec${ext}"
objcopy --compress-debug-sections "$bin" || true
2021-07-21 16:14:03 +02:00
mkdir "$dst"
2021-07-21 16:14:03 +02:00
mkdir -p "target/release"
cp "$bin" "target/release/" # workaround for cargo-deb silliness with targets
cp "$bin" "$dst/"
cp -r crates/cli/README.md LICENSE completions doc/{logo.svg,watchexec.1{,.*}} "$dst/"
- name: Archive (tar)
if: '! startsWith(matrix.name, ''windows-'')'
run: tar cavf "$dst.tar.xz" "$dst"
- name: Archive (deb)
if: startsWith(matrix.name, 'linux-')
run: cargo deb -p watchexec-cli --no-build --no-strip --target ${{ matrix.target }} --output "$dst.deb"
2022-01-18 12:20:23 +01:00
- name: Archive (rpm)
if: startsWith(matrix.name, 'linux-')
shell: bash
run: |
set -euxo pipefail
shopt -s globstar
cargo generate-rpm -p crates/cli --target "${{ matrix.target }}" --target-dir "target/${{ matrix.target }}"
2022-01-18 12:20:23 +01:00
mv target/**/*.rpm "$dst.rpm"
- name: Archive (zip)
if: startsWith(matrix.name, 'windows-')
shell: bash
run: 7z a "$dst.zip" "$dst"
- uses: actions/upload-artifact@v4
with:
name: builds
retention-days: 1
path: |
watchexec-*.tar.xz
watchexec-*.tar.zst
watchexec-*.deb
watchexec-*.rpm
watchexec-*.zip
2023-03-22 05:26:15 +01:00
upload:
needs: [build, info]
name: Checksum and publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install b3sum
uses: taiki-e/install-action@v2
2022-03-18 02:12:23 +01:00
with:
2022-09-07 04:15:38 +02:00
tool: b3sum
2022-09-07 04:15:38 +02:00
- uses: actions/download-artifact@v3
with:
name: builds
- name: Dist manifest
run: |
jq -ncf .github/workflows/dist-manifest.jq \
2023-12-20 02:06:41 +01:00
--arg version "${{ needs.info.outputs.cli_version }}" \
--arg changelog "${{ needs.info.outputs.release_notes }}" \
2023-03-22 05:26:15 +01:00
--arg files "$(ls watchexec-*)" \
> dist-manifest.json
- name: Bulk checksums
run: |
b3sum watchexec-* | tee B3SUMS
sha512sum watchexec-* | tee SHA512SUMS
sha256sum watchexec-* | tee SHA256SUMS
- name: File checksums
run: |
2023-03-18 17:05:14 +01:00
for file in watchexec-*; do
b3sum --no-names $file > "$file.b3"
sha256sum $file | cut -d ' ' -f1 > "$file.sha256"
sha512sum $file | cut -d ' ' -f1 > "$file.sha512"
done
- uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
with:
2022-09-07 08:35:00 +02:00
tag_name: v${{ needs.info.outputs.cli_version }}
name: CLI v${{ needs.info.outputs.cli_version }}
2022-06-29 04:21:57 +02:00
body: ${{ needs.info.outputs.release_notes }}
append_body: true
discussion_category_name: ${{ needs.info.outputs.announce }}
files: |
dist-manifest.json
watchexec-*.tar.xz
watchexec-*.tar.zst
watchexec-*.deb
watchexec-*.rpm
watchexec-*.zip
*SUMS
*.b3
*.sha*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}