|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - target: x86_64-unknown-linux-gnu |
| 17 | + os: ubuntu-latest |
| 18 | + use_cross: false |
| 19 | + - target: aarch64-unknown-linux-gnu |
| 20 | + os: ubuntu-latest |
| 21 | + use_cross: true |
| 22 | + - target: aarch64-apple-darwin |
| 23 | + os: macos-latest |
| 24 | + use_cross: false |
| 25 | + - target: x86_64-apple-darwin |
| 26 | + os: macos-13 |
| 27 | + use_cross: false |
| 28 | + |
| 29 | + runs-on: ${{ matrix.os }} |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - uses: dtolnay/rust-toolchain@stable |
| 35 | + with: |
| 36 | + targets: ${{ matrix.target }} |
| 37 | + |
| 38 | + - name: Install cross |
| 39 | + if: matrix.use_cross |
| 40 | + run: cargo install cross --locked |
| 41 | + |
| 42 | + - name: Build |
| 43 | + run: | |
| 44 | + if [ "${{ matrix.use_cross }}" = "true" ]; then |
| 45 | + cross build --release --target ${{ matrix.target }} |
| 46 | + else |
| 47 | + cargo build --release --target ${{ matrix.target }} |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Package |
| 51 | + run: | |
| 52 | + VERSION="${GITHUB_REF_NAME}" |
| 53 | + ARCHIVE="sqssh-${VERSION}-${{ matrix.target }}.tar.gz" |
| 54 | + BINDIR="target/${{ matrix.target }}/release" |
| 55 | +
|
| 56 | + BINS="" |
| 57 | + for bin in sqssh sqsshd sqscp sqsftp sqssh-keygen sqssh-keyscan sqssh-agent sqssh-add sqssh-copy-id sqsshctl sqssh-persist; do |
| 58 | + if [ -f "${BINDIR}/${bin}" ]; then |
| 59 | + BINS="${BINS} ${BINDIR}/${bin}" |
| 60 | + fi |
| 61 | + done |
| 62 | +
|
| 63 | + tar -czf "${ARCHIVE}" -C "${BINDIR}" $(for b in $BINS; do basename "$b"; done) |
| 64 | + echo "ARCHIVE=${ARCHIVE}" >> $GITHUB_ENV |
| 65 | +
|
| 66 | + - uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: sqssh-${{ matrix.target }} |
| 69 | + path: ${{ env.ARCHIVE }} |
| 70 | + |
| 71 | + release: |
| 72 | + needs: build |
| 73 | + runs-on: ubuntu-latest |
| 74 | + permissions: |
| 75 | + contents: write |
| 76 | + |
| 77 | + steps: |
| 78 | + - uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + merge-multiple: true |
| 81 | + |
| 82 | + - name: Create Release |
| 83 | + uses: softprops/action-gh-release@v2 |
| 84 | + with: |
| 85 | + generate_release_notes: true |
| 86 | + files: sqssh-*.tar.gz |
0 commit comments