Skip to content

Commit

Permalink
Refactor release workflow (#901)
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Wagner <[email protected]>
  • Loading branch information
nwagner84 authored Feb 11, 2025
1 parent 32fefdc commit a1d82aa
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 50 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Release

on:
push:
tags:
- 'v*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUSTDOCFLAGS: "-Dwarnings"
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: 1

permissions:
contents: write

jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get release version
run: |
tag=${{ github.ref_name }}
echo "RELEASE_TAG=$tag" >> $GITHUB_ENV
version=${tag#v}
echo "VERSION=$version" >> $GITHUB_ENV
- name: Show release version
run: |
echo "tag is $RELEASE_TAG"
echo "version is $VERSION"
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "$VERSION" --draft --generate-notes --title "v$VERSION"
outputs:
version: ${{ env.VERSION }}

release:
needs: prepare
strategy:
matrix:
target:
- { os: ubuntu-latest, toolchain: stable, triple: x86_64-unknown-linux-gnu }
- { os: windows-latest, toolchain: stable, triple: i686-pc-windows-msvc }
- { os: macos-latest, toolchain: stable, triple: x86_64-apple-darwin }
runs-on: ${{ matrix.target.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.target.toolchain }}
targets: ${{ matrix.target.triple }}
- name: Test workspace packages
run: |
cargo test -p pica-record --release --all-features
cargo test -p pica-cli --release --all-features
- name: Build release binary
shell: bash
run: |
cargo build -p pica-cli --release --features performant
if [ "${{ matrix.target.os }}" = "windows-latest" ]; then
echo "BINARY=target/release/pica.exe" >> $GITHUB_ENV
else
echo "BINARY=target/release/pica" >> $GITHUB_ENV
fi
- name: Strip release binary
shell: bash
if: matrix.target.os == 'macos-latest'
run:
strip "$BINARY"
- name: Prepare archive
shell: bash
run: |
version="${{ needs.prepare.outputs.version }}"
triple="${{ matrix.target.triple }}"
ARCHIVE="pica-$version-$triple"
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
mkdir -p "$ARCHIVE/complete"
cp "$BINARY" "$ARCHIVE"/
cp "README.md" "$ARCHIVE"/
cp "LICENSE" "$ARCHIVE"/
- name: Generate completions
shell: bash
run: |
$BINARY completions bash -o "$ARCHIVE/complete/pica.bash"
$BINARY completions elvish -o "$ARCHIVE/complete/pica.elv"
$BINARY completions fish -o "$ARCHIVE/complete/pica.fish"
$BINARY completions powershell -o "$ARCHIVE/complete/_pica.ps1"
$BINARY completions zsh -o "$ARCHIVE/complete/_pica"
- name: Build Archive (Windows)
if: matrix.target.os == 'windows-latest'
shell: bash
run: |
7z a "$ARCHIVE.zip" "$ARCHIVE"
certutil -hashfile "$ARCHIVE.zip" SHA256 > "$ARCHIVE.zip.sha256"
echo "ASSET_CHECKSUM=$ARCHIVE.zip.sha256" >> $GITHUB_ENV
echo "ASSET=$ARCHIVE.zip" >> $GITHUB_ENV
- name: Build Archive (Unix)
if: matrix.target.os != 'windows-latest'
shell: bash
run: |
tar czf "$ARCHIVE.tar.gz" "$ARCHIVE"
shasum -a 256 "$ARCHIVE.tar.gz" > "$ARCHIVE.tar.gz.sha256"
echo "ASSET_CHECKSUM=$ARCHIVE.tar.gz.sha256" >> $GITHUB_ENV
echo "ASSET=$ARCHIVE.tar.gz" >> $GITHUB_ENV
- name: Upload assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
version="${{ needs.prepare.outputs.version }}"
gh release upload "$version" ${{ env.ASSET_CHECKSUM }}
gh release upload "$version" ${{ env.ASSET }}
12 changes: 12 additions & 0 deletions crates/pica-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,15 @@ name = "pica"
[[test]]
path = "tests/integration.rs"
name = "integration"

[package.metadata.deb]
features = ["performant"]
section = "utils"
assets = [
["target/release/pica", "usr/bin/", "755"],
["../../README.md", "usr/share/doc/pica/README", "644"],
["../../LICENSE", "usr/share/doc/pica/", "644"],
["../../assets/pica.bash", "usr/share/bash-completions/completions/pica", "644"],
["../../assets/pica.fish", "usr/share/fish/vendor_completions.d/pica.fish", "644"],
["../../assets/pica.zsh", "usr/share/zsh/vendor-completions/_pica", "644"],
]
69 changes: 19 additions & 50 deletions docs/book/install.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,31 @@ muss in dem Befehl entsprechend ersetzt werden.

## Installation unter Linux

Abhängig von der genutzten Linux-Distribution, gibt es
unterschiedliche Möglichkeiten der Installation. Vorgefertigte
[Releases] stehen auf der Plattform GitHub zum Download bereit.

### Debian und Ubuntu

Unter [Debian GNU/Linux] und [Ubuntu Linux] können fertige
*DEB*-Pakete genutzt werden. Diese können mit dem `dpkg`-Programm
installiert werden:

```{.bash}
$ dpkg -i pica_X.Y.Z-glibc2.35-1_amd64.deb
```

### Red Hat, SUSE und CentOS

Für die Distributionen [Red Hat Linux], [SUSE Linux] und [CentOS
Linux] stehen fertige *RPM*-Pakete zum Download bereit, die sich mit
dem `rpm`-Programm installieren lassen:

```{.bash}
$ rpm -i pica-X.Y.Z-glibc2.35-1.x86_64.rpm
```

### Binary Releases

Soll `pica` nicht über einen Paketmanager installiert werden, stehen
für die Zielarchitektur `x86_64-unknown-linux-gnu` mit den
*glibc*-Versionen 2.28, 2.31 und 2.35 fertige *Binary Releases* zur
Verfügung. Die *glibc*-Version des Systems lässt sich mit dem Aufruf
`ldd --version` ermitteln.
Für das Betriebssystem Linux stehen vorgefertigte [Releases] stehen auf der
Plattform GitHub zum Download bereit.

Das `tar`-Archiv enthält neben dem Tool `pica` auch weitere Dateien
wie bspw. Shell-Skripte zur Befehlszeilenergänzung:

```{.bash}
$ tar -tf
pica-X.Y.Z-x86_64-unknown-linux-gnu-glibc2.35.tar.gz
pica-X.Y.Z-x86_64-unknown-linux-gnu-glibc2.35/
pica-X.Y.Z-x86_64-unknown-linux-gnu-glibc2.35/pica
pica-X.Y.Z-x86_64-unknown-linux-gnu-glibc2.35/README.md
pica-X.Y.Z-x86_64-unknown-linux-gnu-glibc2.35/pica.zsh
pica-X.Y.Z-x86_64-unknown-linux-gnu-glibc2.35/LICENSE
pica-X.Y.Z-x86_64-unknown-linux-gnu-glibc2.35/pica.fish
pica-X.Y.Z-x86_64-unknown-linux-gnu-glibc2.35/pica.bash
pica-X.Y.Z-x86_64-unknown-linux-gnu.tar.gz
pica-X.Y.Z-x86_64-unknown-linux-gnu/
pica-X.Y.Z-x86_64-unknown-linux-gnu/pica
pica-X.Y.Z-x86_64-unknown-linux-gnu/README.md
pica-X.Y.Z-x86_64-unknown-linux-gnu/completion/pica.zsh
pica-X.Y.Z-x86_64-unknown-linux-gnu/LICENSE
pica-X.Y.Z-x86_64-unknown-linux-gnu/completion/pica.fish
pica-X.Y.Z-x86_64-unknown-linux-gnu/completion/_pica
```

Eine systemweite Installation von `pica` in das Verzeichnis
`/usr/local/bin` kann mit dem `install` erfolgen. Hierfür sind
ggf. *root*-Rechte nötig:

```{.bash}
$ tar xfz pica-X.Y.Z-x86_64-unknown-linux-gnu-glibc2.35.tar.gz
$ sudo install -m755 pica-X.Y.Z-x86_64-unknown-linux-gnu-glibc2.35/pica \
$ tar xfz pica-X.Y.Z-x86_64-unknown-linux-gnu.tar.gz
$ sudo install -m755 pica-X.Y.Z-x86_64-unknown-linux-gnu/pica \
/usr/local/bin/pica
```

Expand All @@ -78,19 +49,17 @@ $ install -m755 pica-X.Y.Z-x86_64-apple-darwin/pica /usr/local/bin/pica

## Installation unter Windows

Unter Windows (`x86_64-pc-windows-gnu` oder `x86_64-pc-windows-msvc`)
kann das Programm direkt dem `zip`-Archiv entnommen werden. Nach einem
Wechsel in das Verzeichnis, in dem sich die `pica.exe` befindet, kann
das Programm direkt genutzt werden. Soll `pica` aus jedem beliebigen
Verzeichnis heraus aufrufbar sein, dann muss der Installationspfad in
der `PATH`-Umgebungsvariable mit aufgelistet werden.
Unter Windows kann das Programm direkt dem `zip`-Archiv `x86_64-pc-windows-msvc`
entnommen werden. Nach einem Wechsel in das Verzeichnis, in dem sich die
`pica.exe` befindet, kann das Programm direkt genutzt werden. Soll `pica`
aus jedem beliebigen Verzeichnis heraus aufrufbar sein, dann muss der
Installationspfad in der `PATH`-Umgebungsvariable mit aufgelistet werden.


## Aus dem Quellcode installieren

Das Projekt lässt sich auch direkt aus den Quellen
kompilieren. Hierfür wird eine aktuelle Rust-Version (>= 1.74.1) mit
dem Paketmanager `cargo` benötigt.
Das Projekt lässt sich auch direkt aus den Quellen kompilieren. Hierfür wird
eine aktuelle Rust-Version (>= 1.83) mit dem Paketmanager `cargo` benötigt.

Der aktuelle Entwicklungsstand lässt sich wie folgt installieren:

Expand Down

0 comments on commit a1d82aa

Please sign in to comment.