name: Release on: push: tags: - v[0-9]+.[0-9]+.[0-9]+ - v[0-9]+.[0-9]+.[0-9]+-** - latest # Targets: # # - x86_64-apple-darwin # - aarch64-apple-darwin # # - x86_64-pc-windows-msvc # - aarch64-pc-windows-msvc # # - x86_64-unknown-linux-gnu # - aarch64-unknown-linux-gnu # - aarch64-linux-android (fails due to termios) # - armv7-unknown-linux-gnueabihf # # - x86_64-unknown-linux-musl # - aarch64-unknown-linux-musl # # - x86_64-unknown-freebsd # - aarch64-unknown-freebsd (works manually, but cannot cross-compile) # # - x86_64-unknown-netbsd (???) # - aarch64-unknown-netbsd (???) # # - x86_64-unknown-openbsd (???) # - aarch64-unknown-openbsd (fails due to openssl-src) # jobs: macos: name: "Build release on MacOS (${{ matrix.target }})" runs-on: macos-11.0 strategy: matrix: target: - x86_64-apple-darwin - aarch64-apple-darwin steps: - uses: actions/checkout@v3 - name: Install Rust (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable target: ${{ matrix.target }} override: true - uses: Swatinem/rust-cache@v2 - name: Build binary (${{ matrix.target }}) run: | cargo build --release --all-features --target ${{ matrix.target }} mv ./target/${{ matrix.target }}/release/distant ./distant-${{ matrix.target }} chmod +x ./distant-${{ matrix.target }} - name: Upload uses: actions/upload-artifact@v2 with: name: ${{ matrix.target }} path: ./distant-${{ matrix.target }} windows: name: "Build release on Windows (${{ matrix.target }})" runs-on: windows-latest strategy: matrix: target: - x86_64-pc-windows-msvc - aarch64-pc-windows-msvc steps: - uses: actions/checkout@v2 - name: Install Rust (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable target: ${{ matrix.target }} override: true - uses: Swatinem/rust-cache@v2 - name: Build binary (${{ matrix.target }}) run: | cargo build --release --all-features --target ${{ matrix.target }} mv ./target/${{ matrix.target }}/release/distant.exe ./distant-${{ matrix.target }}.exe chmod +x ./distant-${{ matrix.target }}.exe - name: Upload uses: actions/upload-artifact@v2 with: name: ${{ matrix.target }} path: ./distant-${{ matrix.target }}.exe linux: name: "Build release on Linux (${{ matrix.target }})" runs-on: ubuntu-latest strategy: matrix: include: - target: x86_64-unknown-linux-gnu build: --all-features - target: aarch64-unknown-linux-gnu build: --all-features deps: gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu - target: armv7-unknown-linux-gnueabihf build: --all-features deps: gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf - target: x86_64-unknown-linux-musl build: --no-default-features --features ssh2 deps: musl-tools - target: aarch64-unknown-linux-musl build: --no-default-features --features ssh2 deps: musl-tools gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu steps: - uses: actions/checkout@v2 - name: Install Rust (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable target: ${{ matrix.target }} override: true - uses: Swatinem/rust-cache@v2 - name: Install dependencies if: ${{ matrix.deps }} run: | sudo apt update sudo apt install -y ${{ matrix.deps }} - name: Build binary (${{ matrix.target }}) run: | cargo build --release ${{ matrix.build }} --target ${{ matrix.target }} mv ./target/${{ matrix.target }}/release/distant ./distant-${{ matrix.target }} chmod +x ./distant-${{ matrix.target }} - name: Upload uses: actions/upload-artifact@v2 with: name: ${{ matrix.target }} path: ./distant-${{ matrix.target }} bsd: name: "Build release on BSD (${{ matrix.os.target }})" runs-on: ${{ matrix.os.host }} strategy: matrix: os: - name: freebsd architecture: x86-64 version: '13.2' host: macos-12 target: x86_64-unknown-freebsd build: --all-features prepare: pkg install -y openssl gmake lang/rust devel/llvm-devel - name: openbsd architecture: x86-64 version: '7.3' host: macos-12 target: x86_64-unknown-openbsd build: --all-features prepare: pkg_add -I gmake rust llvm steps: - uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - name: Build in FreeBSD uses: cross-platform-actions/action@v0.15.0 with: operating_system: ${{ matrix.os.name }} architecture: ${{ matrix.os.architecture }} version: ${{ matrix.os.version }} shell: bash run: | ${{ matrix.os.prepare }} cargo build --release ${{ matrix.os.build }} --target ${{ matrix.os.target }} mv ./target/${{ matrix.os.target }}/release/distant ./distant-${{ matrix.os.target }} chmod +x ./distant-${{ matrix.os.target }} - name: Upload uses: actions/upload-artifact@v2 with: name: ${{ matrix.os.target }} path: ./distant-${{ matrix.os.target }} publish: needs: [macos, windows, linux, bsd] runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v2 - uses: actions/download-artifact@v2 - name: Generate SHA256 checksums run: | for i in $(find . -name "distant-*" -type f); do echo "Generating checksum for ${i}" sha256sum "${i}" > "${i}.sha256sum" done - 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 or latest id: check-tag run: | if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+-.*$ ]]; then echo ::set-output name=match::true elif [[ ${{ github.ref }} =~ ^refs/tags/latest$ ]]; then echo ::set-output name=latest::true fi - name: Print pre-release status run: | echo "Is ${{ github.ref }} a pre-release: ${{ steps.check-tag.outputs.match }}" echo "Is ${{ github.ref }} latest: ${{ steps.check-tag.outputs.latest }}" - 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: | **/distant-* **/*.sha256sum body: | ## Latest This is the latest commit (${{ github.sha }}) built for testing. This is not guaranteed to pass all tests or even function properly.