1
1
mirror of https://github.com/orhun/git-cliff.git synced 2024-12-15 00:23:16 +03:00
git-cliff/.github/workflows/cd.yml
2021-06-14 22:58:37 +03:00

105 lines
3.7 KiB
YAML

name: Continuous Deployment
on:
push:
tags:
- "v*.*.*"
jobs:
publish-github:
name: Publish on GitHub
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux-gnu, linux-musl, win-gnu, win-msvc, win32-msvc, macos]
include:
- BUILD: linux-gnu
OS: ubuntu-18.04
TOOLCHAIN: stable
TARGET: x86_64-unknown-linux-gnu
- BUILD: linux-musl
OS: ubuntu-18.04
TOOLCHAIN: stable
TARGET: x86_64-unknown-linux-musl
- BUILD: win-gnu
OS: windows-2019
TOOLCHAIN: stable
TARGET: x86_64-pc-windows-gnu
- BUILD: win-msvc
OS: windows-2019
TOOLCHAIN: stable
TARGET: x86_64-pc-windows-msvc
- BUILD: win32-msvc
OS: windows-2019
TOOLCHAIN: stable
TARGET: i686-pc-windows-msvc
- BUILD: macos
OS: macos-10.15
TOOLCHAIN: stable
TARGET: x86_64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@main
- name: Set the release version
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.TOOLCHAIN }}
target: ${{ matrix.TARGET }}
override: true
- name: Build
run: cargo build --release --locked --target ${{ matrix.TARGET }}
- name: Prepare release assets
shell: bash
run: |
mkdir -p release/completions/
cp {LICENSE,README.md,CHANGELOG.md} release/
OUT_DIR=release/completions/ cargo run --release --bin completions
if [ "${{ matrix.OS }}" = "windows-2019" ]; then
cp target/${{ matrix.TARGET }}/release/git-cliff.exe release/
else
cp target/${{ matrix.TARGET }}/release/git-cliff release/
fi
mv release/ git-cliff-${{ env.RELEASE_VERSION }}/
- name: Create release artifacts
run: |
if [ "${{ matrix.OS }}" = "windows-2019" ]; then
7z a -tzip "git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.zip" \
git-cliff-${{ env.RELEASE_VERSION }}/
else
tar -czvf git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz \
git-cliff-${{ env.RELEASE_VERSION }}/
shasum -a 512 git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz \
> git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz.sha512
fi
- name: Sign the release
if: matrix.OS == 'ubuntu-18.04' || matrix.OS == 'macos-10.15'
run: |
echo "${{ secrets.GPG_RELEASE_KEY }}" | base64 --decode > private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --import private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --detach-sign \
git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz
- name: Upload the release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}*
file_glob: true
tag: ${{ github.ref }}
overwrite: true
# publish-crates-io:
# name: Publish on crates.io
# needs: publish-github
# runs-on: ubuntu-18.04
# steps:
# - name: Checkout
# uses: actions/checkout@main
# - name: Publish
# uses: actions-rs/cargo@v1
# with:
# command: publish
# args: --locked --token ${{ secrets.CARGO_TOKEN }}