mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
203 lines
6.4 KiB
YAML
203 lines
6.4 KiB
YAML
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- "**/*.md"
|
|
- "docs/**"
|
|
push:
|
|
branches:
|
|
- main
|
|
- release/*
|
|
paths-ignore:
|
|
- "**/*.md"
|
|
|
|
name: Build release binaries
|
|
|
|
jobs:
|
|
publish:
|
|
name: Publishing ${{ matrix.job.target }}
|
|
runs-on: ${{ matrix.job.os }}
|
|
strategy:
|
|
matrix:
|
|
rust: [stable]
|
|
job:
|
|
- os: windows-latest
|
|
os-name: windows
|
|
target: x86_64-pc-windows-msvc
|
|
architecture: x86_64
|
|
binary-postfix: ""
|
|
use-cross: false
|
|
- os: macos-latest
|
|
os-name: macos
|
|
target: x86_64-apple-darwin
|
|
architecture: x86_64
|
|
binary-postfix: ""
|
|
use-cross: false
|
|
- os: macos-latest
|
|
os-name: macos
|
|
target: aarch64-apple-darwin
|
|
architecture: arm64
|
|
binary-postfix: ""
|
|
use-cross: true
|
|
- os: ubuntu-latest
|
|
os-name: linux
|
|
target: x86_64-unknown-linux-gnu
|
|
architecture: x86_64
|
|
binary-postfix: ""
|
|
use-cross: false
|
|
- os: ubuntu-latest
|
|
os-name: linux
|
|
target: x86_64-unknown-linux-musl
|
|
architecture: x86_64
|
|
binary-postfix: ""
|
|
use-cross: false
|
|
- os: ubuntu-latest
|
|
os-name: linux
|
|
target: aarch64-unknown-linux-gnu
|
|
architecture: arm64
|
|
binary-postfix: ""
|
|
use-cross: true
|
|
- os: ubuntu-latest
|
|
os-name: linux
|
|
target: i686-unknown-linux-gnu
|
|
architecture: i686
|
|
binary-postfix: ""
|
|
use-cross: true
|
|
- os: ubuntu-latest
|
|
os-name: netbsd
|
|
target: x86_64-unknown-netbsd
|
|
architecture: x86_64
|
|
binary-postfix: ""
|
|
use-cross: true
|
|
- os: ubuntu-latest
|
|
os-name: linux
|
|
target: armv7-unknown-linux-gnueabihf
|
|
architecture: armv7
|
|
binary-postfix: ""
|
|
use-cross: true
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Install Rust toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
profile: minimal
|
|
override: true
|
|
target: ${{ matrix.job.target }}
|
|
- name: install compiler
|
|
shell: bash
|
|
run: |
|
|
if [[ ${{ matrix.job.target }} == x86_64-unknown-linux-musl ]]; then
|
|
sudo apt update
|
|
sudo apt-get install -y musl-tools
|
|
fi
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: ${{ matrix.job.target }}
|
|
- name: Set Version
|
|
shell: bash
|
|
run: echo "PROJECT_VERSION=$(git describe --tags)" >> $GITHUB_ENV
|
|
- name: Cargo build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
use-cross: ${{ matrix.job.use-cross }}
|
|
toolchain: ${{ matrix.rust }}
|
|
args: --release --target ${{ matrix.job.target }}
|
|
|
|
- name: Packaging final binary
|
|
if: ${{ !contains(github.ref_name, '/') }}
|
|
shell: bash
|
|
run: |
|
|
cd target/${{ matrix.job.target }}/release
|
|
|
|
########## create tar.gz ##########
|
|
RELEASE_NAME=rustic-${{ github.ref_name }}-${{ matrix.job.target}}
|
|
tar czvf $RELEASE_NAME.tar.gz rustic${{ matrix.job.binary-postfix }}
|
|
|
|
########## create sha256 ##########
|
|
if [[ ${{ runner.os }} == 'Windows' ]]; then
|
|
certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256
|
|
else
|
|
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
|
|
fi
|
|
- name: Storing binary as artefact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: binary-${{ matrix.job.target}}
|
|
path: target/${{ matrix.job.target }}/release/rustic-${{ github.ref_name }}-${{ matrix.job.target}}.tar.gz
|
|
- name: Releasing release versions
|
|
uses: softprops/action-gh-release@v1
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
files: |
|
|
target/${{ matrix.job.target }}/release/rustic-*.tar.gz
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
publish-beta:
|
|
name: Publishing beta-builds
|
|
needs: publish
|
|
if: ${{ github.ref == 'refs/heads/main' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download all workflow run artifacts
|
|
uses: actions/download-artifact@v3
|
|
- name: Releasing beta builds
|
|
shell: bash
|
|
run: |
|
|
# set up some directories
|
|
WORKING_DIR=$(mktemp -d)
|
|
DEST_DIR=beta
|
|
|
|
# set up the github deploy key
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.BETA_RELEASE_KEY }}" > ~/.ssh/id_rsa
|
|
chmod 600 ~/.ssh/id_rsa
|
|
|
|
# set up git
|
|
git config --global user.name "${{ github.actor }}"
|
|
git config --global user.email "${{ github.actor }}"
|
|
ssh-keyscan -H github.com > ~/.ssh/known_hosts
|
|
GIT_SSH='ssh -i ~/.ssh/id_rsa -o UserKnownHostsFile=~/.ssh/known_hosts'
|
|
|
|
# clone the repo into our working directory
|
|
GIT_SSH_COMMAND=$GIT_SSH git clone git@github.com:rustic-rs/rustic-beta.git $WORKING_DIR
|
|
|
|
# ensure destination directory exists
|
|
mkdir -p $WORKING_DIR/$DEST_DIR
|
|
|
|
# do the copy
|
|
for i in binary-*; do cp -a $i/* $WORKING_DIR/$DEST_DIR; done
|
|
|
|
# create the commit
|
|
cd $WORKING_DIR
|
|
git add .
|
|
git commit -m "${{ github.job }} from https://github.com/${{ github.repository }}/commit/${{ github.sha }}" || echo
|
|
GIT_SSH_COMMAND=$GIT_SSH git pull --rebase
|
|
GIT_SSH_COMMAND=$GIT_SSH git push
|
|
|
|
# publish-cargo:
|
|
# name: Publishing to Cargo
|
|
# runs-on: ubuntu-latest
|
|
# steps:
|
|
# - name: Checkout repository
|
|
# uses: actions/checkout@v3
|
|
# - uses: actions-rs/toolchain@v1
|
|
# with:
|
|
# toolchain: stable
|
|
# profile: minimal
|
|
# override: true
|
|
# - uses: Swatinem/rust-cache@v2
|
|
# with:
|
|
# key: ${{ matrix.job.target }}
|
|
# - uses: actions-rs/cargo@v1
|
|
# with:
|
|
# command: publish
|
|
# args: --token ${{ secrets.CARGO_API_KEY }}
|