release #33
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - v* | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Sync version from tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml | |
| sed -i "s/^pkgver=.*/pkgver=${VERSION}/" packaging/arch/PKGBUILD | |
| - name: Update lockfile for tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: cargo generate-lockfile | |
| - name: Install build dependencies | |
| run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config cmake | |
| - name: Test | |
| run: cargo test --locked | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: startsWith(github.ref, 'refs/tags/') | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - x86_64-unknown-linux-gnu | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Sync version from tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml | |
| sed -i "s/^pkgver=.*/pkgver=${VERSION}/" packaging/arch/PKGBUILD | |
| - name: Update lockfile for tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: cargo generate-lockfile | |
| - name: Install build dependencies | |
| run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config cmake | |
| - name: Build | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package | |
| run: | | |
| BIN=target/${{ matrix.target }}/release/ss-ssh | |
| TAR=super-simple-ssh-client-${{ matrix.target }}.tar.gz | |
| tar -czf "$TAR" -C "$(dirname "$BIN")" "$(basename "$BIN")" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-${{ matrix.target }} | |
| path: super-simple-ssh-client-${{ matrix.target }}.tar.gz | |
| build-deb: | |
| runs-on: ubuntu-latest | |
| needs: build-linux | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Sync version from tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml | |
| sed -i "s/^pkgver=.*/pkgver=${VERSION}/" packaging/arch/PKGBUILD | |
| - name: Update lockfile for tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: cargo generate-lockfile | |
| - name: Install build dependencies | |
| run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config cmake | |
| - name: Install cargo-deb | |
| run: cargo install cargo-deb | |
| - name: Build deb | |
| run: cargo deb --locked | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: debian-package | |
| path: target/debian/*.deb | |
| build-rpm: | |
| runs-on: ubuntu-latest | |
| container: fedora:latest | |
| needs: build-linux | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Sync version from tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml | |
| sed -i "s/^pkgver=.*/pkgver=${VERSION}/" packaging/arch/PKGBUILD | |
| - name: Install build dependencies | |
| run: | | |
| dnf install -y git rust cargo gcc make openssl-devel libssh2-devel zlib-devel rpm-build pkgconf-pkg-config | |
| - name: Update lockfile for tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: cargo generate-lockfile | |
| - name: Build rpm | |
| run: | | |
| VERSION=$(grep -m1 '^version' Cargo.toml | cut -d '"' -f2) | |
| sed -i "s/@VERSION@/${VERSION}/" packaging/rpm/ss-ssh.spec | |
| mkdir -p rpmbuild/{SOURCES,SPECS,BUILD,RPMS,SRPMS} | |
| tar -czf "super-simple-ssh-client-${VERSION}.tar.gz" \ | |
| --transform "s,^,super-simple-ssh-client-${VERSION}/," \ | |
| --exclude=.git --exclude=target --exclude=.idea \ | |
| --warning=no-file-changed --ignore-failed-read . | |
| mv "super-simple-ssh-client-${VERSION}.tar.gz" rpmbuild/SOURCES/ | |
| cp packaging/rpm/ss-ssh.spec rpmbuild/SPECS/ | |
| rpmbuild -ba rpmbuild/SPECS/ss-ssh.spec --define "_topdir $(pwd)/rpmbuild" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: fedora-package | |
| path: rpmbuild/RPMS/**/*.rpm | |
| build-arch: | |
| runs-on: ubuntu-latest | |
| container: archlinux:latest | |
| needs: build-linux | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Sync version from tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml | |
| sed -i "s/^pkgver=.*/pkgver=${VERSION}/" packaging/arch/PKGBUILD | |
| - name: Install toolchain | |
| run: | | |
| pacman -Sy --noconfirm --needed base-devel git rust cargo openssl libssh2 zlib pkgconf cmake | |
| - name: Update lockfile for tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: cargo generate-lockfile | |
| - name: Build package | |
| run: | | |
| VERSION=$(grep -m1 '^version' Cargo.toml | cut -d '"' -f2) | |
| sed -i "s/^pkgver=.*/pkgver=${VERSION}/" packaging/arch/PKGBUILD | |
| tar -czf "super-simple-ssh-client-${VERSION}.tar.gz" \ | |
| --transform "s,^,super-simple-ssh-client-${VERSION}/," \ | |
| --exclude=.git --exclude=target --exclude=.idea \ | |
| --warning=no-file-changed --ignore-failed-read . | |
| cp "super-simple-ssh-client-${VERSION}.tar.gz" packaging/arch/ | |
| useradd -m builder | |
| chown -R builder:builder . | |
| su builder -c "cd packaging/arch && makepkg -sf --noconfirm" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: arch-package | |
| path: packaging/arch/*.pkg.tar.zst | |
| build-windows: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: x86_64-pc-windows-gnu | |
| - name: Sync version from tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml | |
| sed -i "s/^pkgver=.*/pkgver=${VERSION}/" packaging/arch/PKGBUILD | |
| - name: Update lockfile for tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: cargo generate-lockfile | |
| - name: Install mingw toolchain | |
| run: sudo apt-get update && sudo apt-get install -y mingw-w64 pkg-config cmake ninja-build | |
| - name: Install vcpkg (mingw) | |
| run: | | |
| git clone https://github.com/microsoft/vcpkg vcpkg | |
| ./vcpkg/bootstrap-vcpkg.sh | |
| ./vcpkg/vcpkg install --triplet x64-mingw-dynamic | |
| - name: Build Windows (GNU) | |
| env: | |
| VCPKG_ROOT: ${{ github.workspace }}/vcpkg | |
| VCPKG_DEFAULT_TRIPLET: x64-mingw-dynamic | |
| PKG_CONFIG_ALLOW_CROSS: "1" | |
| PKG_CONFIG_PATH: ${{ github.workspace }}/vcpkg/installed/x64-mingw-dynamic/lib/pkgconfig | |
| CC_x86_64_pc_windows_gnu: x86_64-w64-mingw32-gcc | |
| CXX_x86_64_pc_windows_gnu: x86_64-w64-mingw32-g++ | |
| AR_x86_64_pc_windows_gnu: x86_64-w64-mingw32-ar | |
| RANLIB_x86_64_pc_windows_gnu: x86_64-w64-mingw32-ranlib | |
| LIBSSH2_SYS_USE_PKG_CONFIG: "1" | |
| run: cargo build --release --target x86_64-pc-windows-gnu | |
| - name: Install Velopack | |
| run: | | |
| curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0 | |
| export PATH="$HOME/.dotnet:$HOME/.dotnet/tools:$PATH" | |
| dotnet tool install -g vpk | |
| echo "$HOME/.dotnet" >> "$GITHUB_PATH" | |
| echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH" | |
| - name: Package (Velopack) | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| vpk pack -u super-simple-ssh-client -v "$VERSION" \ | |
| -p target/x86_64-pc-windows-gnu/release -e ss-ssh.exe -o dist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-x86_64 | |
| path: dist/* | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-linux | |
| - build-deb | |
| - build-rpm | |
| - build-arch | |
| - build-windows | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Resolve version | |
| id: version | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| else | |
| VERSION=$(grep -m1 '^version' Cargo.toml | cut -d '"' -f2) | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "tag=v$VERSION" >> "$GITHUB_OUTPUT" | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Create release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG=${{ steps.version.outputs.tag }} | |
| if gh release view "$TAG" >/dev/null 2>&1; then | |
| echo "Release $TAG already exists." | |
| exit 0 | |
| fi | |
| gh release create "$TAG" --title "$TAG" --notes "Release $TAG" | |
| find dist -maxdepth 3 -type f -print -exec gh release upload "$TAG" {} \; |