mirror of
https://github.com/chipsenkbeil/distant.git
synced 2024-11-05 12:00:36 +00:00
253 lines
9.2 KiB
YAML
253 lines
9.2 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- v[0-9]+.[0-9]+.[0-9]+
|
|
- v[0-9]+.[0-9]+.[0-9]+-**
|
|
|
|
jobs:
|
|
macos:
|
|
name: "Build release on MacOS"
|
|
runs-on: macos-11.0
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
env:
|
|
UPLOAD_NAME: macos
|
|
X86_ARCH: x86_64-apple-darwin
|
|
ARM_ARCH: aarch64-apple-darwin
|
|
X86_DIR: target/x86_64-apple-darwin/release
|
|
ARM_DIR: target/aarch64-apple-darwin/release
|
|
BUILD_BIN: distant
|
|
UNIVERSAL_REL_BIN: distant-macos
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Install Rust (x86)
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
target: ${{ env.X86_ARCH }}
|
|
- name: Install Rust (ARM)
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
target: ${{ env.ARM_ARCH }}
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Build binary (x86_64)
|
|
run: |
|
|
cargo build --release --all-features --target ${{ env.X86_ARCH }}
|
|
ls -l ./${{ env.X86_DIR }}
|
|
strip ./${{ env.X86_DIR }}/${{ env.BUILD_BIN }}
|
|
- name: Build binary (aarch64)
|
|
run: |
|
|
cargo build --release --all-features --target ${{ env.ARM_ARCH }}
|
|
ls -l ./${{ env.ARM_DIR }}
|
|
strip ./${{ env.ARM_DIR }}/${{ env.BUILD_BIN }}
|
|
- name: Unify binaries
|
|
run: |
|
|
lipo -create -output ${{ env.UNIVERSAL_REL_BIN }} \
|
|
./${{ env.X86_DIR }}/${{ env.BUILD_BIN }} \
|
|
./${{ env.ARM_DIR }}/${{ env.BUILD_BIN }}
|
|
chmod +x ./${{ env.UNIVERSAL_REL_BIN }}
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: ${{ env.UPLOAD_NAME }}
|
|
path: |
|
|
${{ env.UNIVERSAL_REL_BIN }}
|
|
|
|
windows:
|
|
name: "Build release on Windows"
|
|
runs-on: windows-latest
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
env:
|
|
UPLOAD_NAME: win64
|
|
X86_ARCH: x86_64-pc-windows-msvc
|
|
X86_DIR: target/x86_64-pc-windows-msvc/release
|
|
BUILD_BIN: distant.exe
|
|
X86_REL_BIN: distant-win64.exe
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Install Rust (MSVC)
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
target: ${{ env.X86_ARCH }}
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Build binary (x86_64)
|
|
run: |
|
|
cargo build --release --all-features --target ${{ env.X86_ARCH }}
|
|
ls -l ./${{ env.X86_DIR }}
|
|
strip ./${{ env.X86_DIR }}/${{ env.BUILD_BIN }}
|
|
mv ./${{ env.X86_DIR }}/${{ env.BUILD_BIN }} ./${{ env.X86_REL_BIN }}
|
|
chmod +x ./${{ env.X86_REL_BIN }}
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: ${{ env.UPLOAD_NAME }}
|
|
path: |
|
|
${{ env.X86_REL_BIN }}
|
|
|
|
linux_gnu:
|
|
name: "Build release on Linux (gnu)"
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
env:
|
|
UPLOAD_NAME: linux64-gnu
|
|
X86_GNU_ARCH: x86_64-unknown-linux-gnu
|
|
X86_GNU_DIR: target/x86_64-unknown-linux-gnu/release
|
|
BUILD_BIN: distant
|
|
X86_GNU_REL_BIN: distant-linux64-gnu
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Install Rust (GNU)
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
target: ${{ env.X86_GNU_ARCH }}
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Build binary (GNU x86_64)
|
|
run: |
|
|
cargo build --release --all-features --target ${{ env.X86_GNU_ARCH }}
|
|
ls -l ./${{ env.X86_GNU_DIR }}
|
|
strip ./${{ env.X86_GNU_DIR }}/${{ env.BUILD_BIN }}
|
|
mv ./${{ env.X86_GNU_DIR }}/${{ env.BUILD_BIN }} ./${{ env.X86_GNU_REL_BIN }}
|
|
chmod +x ./${{ env.X86_GNU_REL_BIN }}
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: ${{ env.UPLOAD_NAME }}
|
|
path: |
|
|
${{ env.X86_GNU_REL_BIN }}
|
|
|
|
# NOTE: For musl, we only support ssh2 and not libssh for the time being due to some
|
|
# build issue with libssh-rs-sys not finding the symbol ENGINE_cleanup in libcrypto
|
|
linux_musl:
|
|
name: "Build release on Linux (musl)"
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: alpine:3.14
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
env:
|
|
UPLOAD_NAME: linux64-musl
|
|
X86_MUSL_ARCH: x86_64-unknown-linux-musl
|
|
X86_MUSL_DIR: target/x86_64-unknown-linux-musl/release
|
|
BUILD_BIN: distant
|
|
X86_MUSL_REL_BIN: distant-linux64-musl
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Install base dependencies
|
|
run: |
|
|
apk add --update --no-cache build-base libc6-compat curl perl
|
|
- name: Install Rust (MUSL)
|
|
run: |
|
|
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Build binary (MUSL x86_64)
|
|
run: |
|
|
source $HOME/.cargo/env
|
|
cargo build --release --no-default-features --features ssh2 --target ${{ env.X86_MUSL_ARCH }}
|
|
ls -l ./${{ env.X86_MUSL_DIR }}
|
|
strip ./${{ env.X86_MUSL_DIR }}/${{ env.BUILD_BIN }}
|
|
mv ./${{ env.X86_MUSL_DIR }}/${{ env.BUILD_BIN }} ./${{ env.X86_MUSL_REL_BIN }}
|
|
chmod +x ./${{ env.X86_MUSL_REL_BIN }}
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: ${{ env.UPLOAD_NAME }}
|
|
path: |
|
|
${{ env.X86_MUSL_REL_BIN }}
|
|
|
|
publish:
|
|
needs: [macos, windows, linux_gnu, linux_musl]
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
permissions:
|
|
contents: write
|
|
env:
|
|
MACOS: macos
|
|
MACOS_UNIVERSAL_BIN: distant-macos
|
|
WIN64: win64
|
|
WIN64_BIN: distant-win64.exe
|
|
LINUX64_GNU: linux64-gnu
|
|
LINUX64_GNU_BIN: distant-linux64-gnu
|
|
LINUX64_MUSL: linux64-musl
|
|
LINUX64_MUSL_BIN: distant-linux64-musl
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/download-artifact@v2
|
|
- name: Generate MacOS SHA256 checksums
|
|
run: |
|
|
cd ${{ env.MACOS }}
|
|
sha256sum ${{ env.MACOS_UNIVERSAL_BIN }} > ${{ env.MACOS_UNIVERSAL_BIN }}.sha256sum
|
|
echo "SHA_MACOS_BIN=$(cat ${{ env.MACOS_UNIVERSAL_BIN }}.sha256sum)" >> $GITHUB_ENV
|
|
- name: Generate Win64 SHA256 checksums
|
|
run: |
|
|
cd ${{ env.WIN64 }}
|
|
sha256sum ${{ env.WIN64_BIN }} > ${{ env.WIN64_BIN }}.sha256sum
|
|
echo "SHA_WIN64_BIN=$(cat ${{ env.WIN64_BIN }}.sha256sum)" >> $GITHUB_ENV
|
|
- name: Generate Linux64 (gnu) SHA256 checksums
|
|
run: |
|
|
cd ${{ env.LINUX64_GNU }}
|
|
sha256sum ${{ env.LINUX64_GNU_BIN }} > ${{ env.LINUX64_GNU_BIN }}.sha256sum
|
|
echo "SHA_LINUX64_GNU_BIN=$(cat ${{ env.LINUX64_GNU_BIN }}.sha256sum)" >> $GITHUB_ENV
|
|
- name: Generate Linux64 (musl) SHA256 checksums
|
|
run: |
|
|
cd ${{ env.LINUX64_MUSL }}
|
|
sha256sum ${{ env.LINUX64_MUSL_BIN }} > ${{ env.LINUX64_MUSL_BIN }}.sha256sum
|
|
echo "SHA_LINUX64_MUSL_BIN=$(cat ${{ env.LINUX64_MUSL_BIN }}.sha256sum)" >> $GITHUB_ENV
|
|
- name: Determine git tag
|
|
if: github.event_name == 'push'
|
|
run: |
|
|
TAG_NAME=${{ github.ref }}
|
|
echo "TAG_NAME=${TAG_NAME#refs/tags/}" >> $GITHUB_ENV
|
|
echo "TAG_VERSION=${TAG_NAME#refs/tags/v}" >> $GITHUB_ENV
|
|
- name: Check git tag for pre-release
|
|
id: check-tag
|
|
run: |
|
|
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+-.*$ ]]; then
|
|
echo ::set-output name=match::true
|
|
fi
|
|
- name: Print pre-release status
|
|
run: |
|
|
echo "Is ${{ github.ref }} a pre-release: ${{ steps.check-tag.outputs.match }}"
|
|
- name: Get Changelog Entry
|
|
id: changelog
|
|
uses: mindsers/changelog-reader-action@v2
|
|
with:
|
|
version: ${{ env.TAG_VERSION }}
|
|
path: "./CHANGELOG.md"
|
|
- name: Publish
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
name: distant ${{ env.TAG_NAME }}
|
|
fail_on_unmatched_files: true
|
|
target_commitish: ${{ github.sha }}
|
|
draft: false
|
|
prerelease: ${{ steps.check-tag.outputs.match == 'true' }}
|
|
files: |
|
|
${{ env.MACOS }}/${{ env.MACOS_UNIVERSAL_BIN }}
|
|
${{ env.WIN64 }}/${{ env.WIN64_BIN }}
|
|
${{ env.LINUX64_GNU }}/${{ env.LINUX64_GNU_BIN }}
|
|
${{ env.LINUX64_MUSL }}/${{ env.LINUX64_MUSL_BIN }}
|
|
**/*.sha256sum
|
|
body: |
|
|
## Release Notes
|
|
${{ steps.changelog.outputs.changes }}
|
|
## Binaries
|
|
Standalone binaries are built out for Windows (x86_64), MacOS (Intel & ARM), and Linux (x86_64).
|
|
- **linux64-gnu** is the x86-64 release on Linux using libc
|
|
- **linux64-musl** is the x86-64 release on Linux using musl (static binary, no libc dependency)
|
|
- **macos** is a universal binary for Mac OS that supports x86-64 and aarch64 (arm) platforms
|
|
- **win64** is the x86-64 release on Windows using MSVC
|
|
## SHA256 Checksums
|
|
```
|
|
${{ env.SHA_MACOS_BIN }}
|
|
${{ env.SHA_WIN64_BIN }}
|
|
${{ env.SHA_LINUX64_GNU_BIN }}
|
|
${{ env.SHA_LINUX64_MUSL_BIN }}
|
|
```
|