Fix CLI release workflow (#339, #340, #341, #342, #343)

This commit is contained in:
Félix Saparelli 2022-06-23 10:29:04 +00:00 committed by Félix Saparelli
parent 77d4b03398
commit ede4959102
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
4 changed files with 62 additions and 53 deletions

View File

@ -1,12 +1,35 @@
name: CLI Release
on:
workflow_call:
workflow_dispatch:
push:
tags:
- "cli-v*.*.*"
jobs:
info:
name: Gather info
runs-on: ubuntu-latest
outputs:
cli_version: ${{ steps.version.outputs.cli_version }}
steps:
- uses: actions/checkout@v2
- 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
echo "::set-output name=cli_version::$version"
build:
strategy:
matrix:
@ -82,9 +105,14 @@ jobs:
# experimental: true
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@v2
- uses: actions/cache@v2
@ -130,20 +158,6 @@ jobs:
command: build
args: --package watchexec-cli --release --locked --target ${{ matrix.target }}
- name: Extract version
shell: bash
run: |
set -euxo pipefail
version=$(grep -m1 -F 'version =' cli/Cargo.toml | cut -d\" -f2)
if [[ -z "$version" ]]; then
echo "Error: no version :("
exit 1
fi
echo "$version" > VERSION
- name: Package
shell: bash
run: |
@ -153,50 +167,31 @@ jobs:
bin="target/${{ matrix.target }}/release/watchexec${ext}"
objcopy --compress-debug-sections "$bin" || strip "$bin" || true
version=$(cat VERSION)
dst="watchexec-${version}-${{ matrix.target }}"
mkdir "$dst"
mkdir -p "target/release"
cp "$bin" "target/release/" # workaround for cargo-deb silliness with targets
cp "$bin" "$dst/"
cp -r cli/README.md LICENSE completions doc/{logo.svg,watchexec.1{,.html}} "$dst/"
cp -r crates/cli/README.md LICENSE completions doc/{logo.svg,watchexec.1{,.html}} "$dst/"
- name: Archive (tar)
if: '! startsWith(matrix.name, ''windows-'')'
shell: bash
run: |
set -euxo pipefail
version=$(cat VERSION)
dst="watchexec-${version}-${{ matrix.target }}"
tar cavf "$dst.tar.xz" "$dst"
run: tar cavf "$dst.tar.xz" "$dst"
- name: Archive (deb)
if: startsWith(matrix.name, 'linux-')
shell: bash
run: |
set -euxo pipefail
version=$(cat VERSION)
dst="watchexec-${version}-${{ matrix.target }}"
cargo deb -p watchexec-cli --no-build --no-strip --target ${{ matrix.target }} --output "$dst.deb"
run: cargo deb -p watchexec-cli --no-build --no-strip --target ${{ matrix.target }} --output "$dst.deb"
- name: Archive (rpm)
if: startsWith(matrix.name, 'linux-')
shell: bash
run: |
set -euxo pipefail
shopt -s globstar
version=$(cat VERSION)
dst="watchexec-${version}-${{ matrix.target }}"
cargo generate-rpm -p cli --target "${{ matrix.target }}" --target-dir "target/${{ matrix.target }}"
cargo generate-rpm -p crates/cli --target "${{ matrix.target }}" --target-dir "target/${{ matrix.target }}"
mv target/**/*.rpm "$dst.rpm"
- name: Archive (zip)
if: startsWith(matrix.name, 'windows-')
shell: bash
run: |
set -euxo pipefail
version=$(cat VERSION)
dst="watchexec-${version}-${{ matrix.target }}"
7z a "$dst.zip" "$dst"
run: 7z a "$dst.zip" "$dst"
- uses: actions/upload-artifact@v2
with:
@ -210,11 +205,15 @@ jobs:
watchexec-*.zip
sign:
needs: build
needs: [build, info]
name: Checksum and sign
runs-on: ubuntu-latest
env:
version: ${{ needs.info.outputs.cli_version }}
tag_name: cli-v${{ needs.info.outputs.cli_version }}
steps:
- uses: actions/checkout@v2
@ -248,7 +247,6 @@ jobs:
set -u
echo "$RELEASE_KEY" > release.key
set -x
version=$(grep -m1 -F 'version =' cli/Cargo.toml | cut -d\" -f2)
for algo in B3 SHA512; do
echo | rsign sign \
-p .github/workflows/release.pub \
@ -263,6 +261,7 @@ jobs:
- uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.tag_name }}
files: |
watchexec-*.tar.xz
watchexec-*.tar.zst

View File

@ -13,6 +13,9 @@ jobs:
# that are named `release: {crate-name} v{version}` will get tagged!
# the commit message will look like: `release: {crate-name} v{version} (#{pr-number})`
if: "startsWith(github.event.head_commit.message, 'release: ')"
outputs:
tag_name: ${{ steps.extract.outputs.tag }}
steps:
- name: Extract tag from commit message
env:
@ -24,6 +27,7 @@ jobs:
crate="$(cut -d ' ' -f 2 <<< "${message}")"
version="$(cut -d ' ' -f 3 <<< "${message}")"
echo "CUSTOM_TAG=${crate}-${version}" >> $GITHUB_ENV
echo "::set-output name=tag::${crate}-${version}"
- uses: actions/checkout@v2
- name: Push release tag
@ -33,3 +37,9 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ env.CUSTOM_TAG }}
tag_prefix: ''
release-cli:
needs: make-tag
if: "startsWith(needs.make-tag.outputs.tag_name, 'cli-v')"
uses: ./.github/workflows/release-cli.yml
secrets: inherit

View File

@ -99,25 +99,25 @@ pkg-fmt = "zip"
[package.metadata.deb]
maintainer = "Félix Saparelli <felix@passcod.name>"
license-file = ["../LICENSE", "0"]
license-file = ["../../LICENSE", "0"]
section = "utility"
# conf-files = [] # look me up when config file lands
assets = [
["../target/release/watchexec", "usr/bin/", "755"],
["../../target/release/watchexec", "usr/bin/", "755"],
["README.md", "usr/share/doc/watchexec/README", "644"],
["../doc/watchexec.1.html", "usr/share/doc/watchexec/watchexec.1.html", "644"],
["../doc/watchexec.1", "usr/share/man/man1/watchexec.1.html", "644"],
["../completions/zsh", "usr/share/zsh/site-functions/_watchexec", "644"],
["../doc/logo.svg", "usr/share/icons/hicolor/scalable/apps/watchexec.svg", "644"],
["../../doc/watchexec.1.html", "usr/share/doc/watchexec/watchexec.1.html", "644"],
["../../doc/watchexec.1", "usr/share/man/man1/watchexec.1.html", "644"],
["../../completions/zsh", "usr/share/zsh/site-functions/_watchexec", "644"],
["../../doc/logo.svg", "usr/share/icons/hicolor/scalable/apps/watchexec.svg", "644"],
]
[package.metadata.generate-rpm]
assets = [
{ source = "../target/release/watchexec", dest = "/usr/bin/", mode = "755" },
{ source = "../cli/README.md", dest = "/usr/share/doc/watchexec/README", mode = "644", doc = true },
{ source = "../doc/watchexec.1.html", dest = "/usr/share/doc/watchexec/watchexec.1.html", mode = "644", doc = true },
{ source = "../doc/watchexec.1", dest = "/usr/share/man/man1/watchexec.1.html", mode = "644" },
{ source = "../completions/zsh", dest = "/usr/share/zsh/site-functions/_watchexec", mode = "644" },
{ source = "../doc/logo.svg", dest = "/usr/share/icons/hicolor/scalable/apps/watchexec.svg", mode = "644" },
{ source = "../../target/release/watchexec", dest = "/usr/bin/", mode = "755" },
{ source = "README.md", dest = "/usr/share/doc/watchexec/README", mode = "644", doc = true },
{ source = "../../doc/watchexec.1.html", dest = "/usr/share/doc/watchexec/watchexec.1.html", mode = "644", doc = true },
{ source = "../../doc/watchexec.1", dest = "/usr/share/man/man1/watchexec.1.html", mode = "644" },
{ source = "../../completions/zsh", dest = "/usr/share/zsh/site-functions/_watchexec", mode = "644" },
{ source = "../../doc/logo.svg", dest = "/usr/share/icons/hicolor/scalable/apps/watchexec.svg", mode = "644" },
# set conf = true for config file when that lands
]

View File

@ -1,5 +1,5 @@
---
source: cli/tests/help.rs
source: crates/cli/tests/help.rs
assertion_line: 16
expression: "String::from_utf8(output.stdout).unwrap()"
---