Skip to content

Change to use Params::default #489

Change to use Params::default

Change to use Params::default #489

Workflow file for this run

# SPDX-FileCopyrightText: 2022 Shun Sakai
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
name: CD
on:
pull_request:
push:
branches:
- "develop"
tags:
- "scryptenc-cli-v[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
env:
CARGO_PROFILE_RELEASE_LTO: true
CARGO_PROFILE_RELEASE_PANIC: "abort"
jobs:
get-version:
name: Get version
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get_version.outputs.version }}
version_without_v: ${{ steps.get_version_without_v.outputs.version-without-v }}
steps:
- name: Get version
id: get_version
shell: bash
run: |
ref_name="${GITHUB_REF_NAME##*/}"
if [[ "${ref_name}" =~ ^scryptenc-cli-v.* ]] ; then
ref_name="${ref_name##*-}"
fi
echo "version=${ref_name}" >> "$GITHUB_OUTPUT"
- name: Get version without v
id: get_version_without_v
run: echo "version-without-v=${GITHUB_REF_NAME##*-v}" >> "$GITHUB_OUTPUT"
build:
name: Build
needs: get-version
runs-on: ${{ matrix.os }}
strategy:
matrix:
target:
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-musl
- aarch64-apple-darwin
- x86_64-apple-darwin
- aarch64-pc-windows-msvc
- x86_64-pc-windows-msvc
include:
- target: aarch64-unknown-linux-musl
os: ubuntu-22.04
use-cross: true
- target: x86_64-unknown-linux-musl
os: ubuntu-22.04
use-cross: true
- target: aarch64-apple-darwin
os: macos-14
- target: x86_64-apple-darwin
os: macos-14
- target: aarch64-pc-windows-msvc
os: windows-2022
- target: x86_64-pc-windows-msvc
os: windows-2022
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install cross
if: ${{ matrix.use-cross }}
uses: taiki-e/[email protected]
with:
tool: cross
- name: Cache build artifacts
uses: Swatinem/[email protected]
with:
key: ${{ matrix.target }}
- name: Setup Ruby
if: matrix.os != 'windows-2022' && !matrix.use-cross
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- name: Install Asciidoctor
if: matrix.os != 'windows-2022' && !matrix.use-cross
run: |
gem install asciidoctor
asciidoctor -V
- name: Build a package
if: ${{ !matrix.use-cross }}
run: cargo build -p scryptenc-cli --release --target ${{ matrix.target }}
- name: Build a package with cross
if: ${{ matrix.use-cross }}
run: cross build -p scryptenc-cli --release --target ${{ matrix.target }}
- name: Create a package
shell: bash
run: |
if [ "${{ matrix.os }}" != "windows-2022" ] ; then
bin="target/${{ matrix.target }}/release/rscrypt"
else
bin="target/${{ matrix.target }}/release/rscrypt.exe"
fi
package="rscrypt-${{ needs.get-version.outputs.version }}-${{ matrix.target }}"
mkdir -p "${package}"/docs
cp crates/cli/README.md "${bin}" "${package}"
cp -r LICENSES "${package}"
cp crates/cli/{AUTHORS,BUILD,CHANGELOG,CONTRIBUTING}.adoc "${package}"/docs
if [ "${{ matrix.os }}" != "windows-2022" ] ; then
mkdir -p "${package}"/man
cp "$(find ./target -path '*/scryptenc-cli-*/out' -type d)"/* "${package}"/man
fi
if [ "${{ matrix.os }}" != "windows-2022" ] ; then
tar -cvf "${package}.tar" "${package}"
zstd --rm -19 -v "${package}.tar"
else
7z a -bb -mx=9 -m0=LZMA "${package}.7z" "${package}"
fi
rm -rv rscrypt-*/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: "rscrypt-${{ needs.get-version.outputs.version }}-${{ matrix.target }}"
path: "rscrypt-*-*"
release:
name: Release
needs:
- get-version
- build
runs-on: ubuntu-22.04
steps:
- name: Download artifact
uses: actions/download-artifact@v4
- name: Calculate checksums
run: |
mv rscrypt-*/* .
rmdir -v rscrypt-*/
sha256sum rscrypt-* | tee sha256sums.txt
b2sum rscrypt-* | tee b2sums.txt
- name: Release
uses: softprops/[email protected]
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: |
rscrypt-*
sha256sums.txt
b2sums.txt
name: "Release scryptenc-cli version ${{ needs.get-version.outputs.version_without_v }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}