| 1 | name: Release |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | tags: ['v*'] |
| 6 | |
| 7 | permissions: |
| 8 | contents: write |
| 9 | |
| 10 | env: |
| 11 | CARGO_TERM_COLOR: always |
| 12 | |
| 13 | jobs: |
| 14 | release: |
| 15 | name: build and publish |
| 16 | runs-on: ubuntu-latest |
| 17 | # Built on Arch: the binary links the system dav1d and libheif, so it suits Arch and other |
| 18 | # rolling distros. Elsewhere, build from source. |
| 19 | container: archlinux:latest |
| 20 | steps: |
| 21 | - name: Install system dependencies |
| 22 | run: | |
| 23 | pacman -Syu --noconfirm --needed base-devel git pkgconf rustup github-cli \ |
| 24 | dav1d libheif libxkbcommon wayland |
| 25 | rustup default stable |
| 26 | - uses: actions/checkout@v7 |
| 27 | - name: Check the tag matches Cargo.toml |
| 28 | run: | |
| 29 | version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)" |
| 30 | test "v$version" = "$GITHUB_REF_NAME" || { echo "tag $GITHUB_REF_NAME, Cargo.toml $version"; exit 1; } |
| 31 | - run: cargo test --locked --release |
| 32 | - run: cargo build --locked --release |
| 33 | - name: Package |
| 34 | run: | |
| 35 | name="remage-${GITHUB_REF_NAME}-x86_64-linux" |
| 36 | dir="dist/$name" |
| 37 | mkdir -p "$dir/completions" "$dir/contrib" |
| 38 | install -m755 -s target/release/remage "$dir/" |
| 39 | target/release/remage man > "$dir/remage.1" |
| 40 | target/release/remage completions zsh > "$dir/completions/_remage" |
| 41 | target/release/remage completions bash > "$dir/completions/remage.bash" |
| 42 | target/release/remage completions fish > "$dir/completions/remage.fish" |
| 43 | cp -r contrib/remage.desktop contrib/config.example.toml contrib/matugen contrib/pywal "$dir/contrib/" |
| 44 | cp README.md LICENSE "$dir/" |
| 45 | cp assets/fonts/OFL.txt "$dir/OFL-fonts.txt" |
| 46 | tar -C dist -czf "dist/$name.tar.gz" "$name" |
| 47 | (cd dist && sha256sum "$name.tar.gz" > "$name.tar.gz.sha256") |
| 48 | - name: Release notes from CHANGELOG.md |
| 49 | run: | |
| 50 | version="${GITHUB_REF_NAME#v}" |
| 51 | awk -v v="$version" '/^## /{p = index($0, "[" v "]") > 0; next} p' CHANGELOG.md > notes.md |
| 52 | test -s notes.md || { echo "no CHANGELOG.md section for $version"; exit 1; } |
| 53 | - name: Publish |
| 54 | env: |
| 55 | GH_TOKEN: ${{ github.token }} |
| 56 | run: | |
| 57 | git config --global --add safe.directory "$GITHUB_WORKSPACE" |
| 58 | gh release create "$GITHUB_REF_NAME" --title "remage $GITHUB_REF_NAME" \ |
| 59 | --notes-file notes.md dist/*.tar.gz dist/*.sha256 |