name: Continuous Deployment
on:
push:
tags:
- "v*.*.*"
jobs:
publish-github:
name: Publish on GitHub
runs-on: ${{ matrix.config.OS }}
strategy:
fail-fast: false
matrix:
config:
- { OS: ubuntu-latest, TARGET: "x86_64-unknown-linux-gnu" }
- { OS: ubuntu-latest, TARGET: "x86_64-unknown-linux-musl" }
- { OS: ubuntu-latest, TARGET: "i686-unknown-linux-gnu" }
- { OS: ubuntu-latest, TARGET: "i686-unknown-linux-musl" }
- { OS: ubuntu-latest, TARGET: "armv5te-unknown-linux-gnueabi" }
- { OS: ubuntu-latest, TARGET: "armv7-unknown-linux-gnueabihf" }
- { OS: ubuntu-latest, TARGET: "aarch64-unknown-linux-gnu" }
- { OS: ubuntu-latest, TARGET: "aarch64-unknown-linux-musl" }
- { OS: macos-latest, TARGET: "x86_64-apple-darwin" }
- { OS: macos-latest, TARGET: "aarch64-apple-darwin" }
- { OS: windows-latest, TARGET: "x86_64-pc-windows-msvc" }
- { OS: windows-latest, TARGET: "i686-pc-windows-msvc" }
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set the release version
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install musl-tools
if: ${{ endsWith(matrix.config.TARGET, 'musl') }}
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
--allow-unauthenticated musl-tools
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.config.TARGET }}
- name: Install cross
uses: taiki-e/install-action@cross
- name: Build
run: cross build --release --locked --target ${{ matrix.config.TARGET }}
- name: Prepare release assets
shell: bash
run: |
mkdir release/
cp {LICENSE,README.md,CHANGELOG.md,config.toml} release/
cp target/${{ matrix.config.TARGET }}/release/rpaste release/
mv release/ rustypaste-cli-${{ env.RELEASE_VERSION }}/
- name: Create release artifacts
shell: bash
run: |
if [ "${{ matrix.config.OS }}" = "windows-latest" ]; then
7z a -tzip "rustypaste-cli-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.zip" \
rustypaste-cli-${{ env.RELEASE_VERSION }}
else
tar -czvf rustypaste-cli-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz \
rustypaste-cli-${{ env.RELEASE_VERSION }}/
shasum -a 512 rustypaste-cli-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz \
> rustypaste-cli-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz.sha512
fi
- name: Upload the release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: rustypaste-cli-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.*
file_glob: true
overwrite: true
tag: ${{ github.ref }}
publish-crates-io:
name: Publish on crates.io
needs: publish-github
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish
run: cargo publish --locked --token ${{ secrets.CARGO_TOKEN }}