mirror of
https://github.com/orhun/git-cliff.git
synced 2024-12-12 06:44:03 +03:00
b136fcb53e
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
409 lines
15 KiB
YAML
409 lines
15 KiB
YAML
name: Continuous Deployment
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
|
|
jobs:
|
|
generate-changelog:
|
|
name: Generate changelog
|
|
runs-on: ubuntu-22.04
|
|
outputs:
|
|
release_body: ${{ steps.git-cliff.outputs.content }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Generate a changelog
|
|
uses: orhun/git-cliff-action@main
|
|
id: git-cliff
|
|
with:
|
|
config: cliff.toml
|
|
args: -vv --latest --strip header
|
|
env:
|
|
OUTPUT: CHANGES.md
|
|
|
|
publish-binaries:
|
|
name: Publish binaries
|
|
needs: generate-changelog
|
|
runs-on: ${{ matrix.build.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
build:
|
|
- {
|
|
NAME: linux-x64-glibc,
|
|
OS: ubuntu-22.04,
|
|
TOOLCHAIN: stable,
|
|
TARGET: x86_64-unknown-linux-gnu,
|
|
NPM_PUBLISH: true,
|
|
PYPI_PUBLISH: true,
|
|
}
|
|
- {
|
|
NAME: linux-x64-musl,
|
|
OS: ubuntu-22.04,
|
|
TOOLCHAIN: stable,
|
|
TARGET: x86_64-unknown-linux-musl,
|
|
NPM_PUBLISH: false,
|
|
PYPI_PUBLISH: true,
|
|
}
|
|
- {
|
|
NAME: linux-x86-glibc,
|
|
OS: ubuntu-22.04,
|
|
TOOLCHAIN: stable,
|
|
TARGET: i686-unknown-linux-gnu,
|
|
NPM_PUBLISH: false,
|
|
PYPI_PUBLISH: true,
|
|
}
|
|
- {
|
|
NAME: linux-x86-musl,
|
|
OS: ubuntu-22.04,
|
|
TOOLCHAIN: stable,
|
|
TARGET: i686-unknown-linux-musl,
|
|
NPM_PUBLISH: false,
|
|
PYPI_PUBLISH: true,
|
|
}
|
|
- {
|
|
NAME: linux-arm64-glibc,
|
|
OS: ubuntu-22.04,
|
|
TOOLCHAIN: stable,
|
|
TARGET: aarch64-unknown-linux-gnu,
|
|
NPM_PUBLISH: true,
|
|
PYPI_PUBLISH: true,
|
|
}
|
|
- {
|
|
NAME: linux-arm64-musl,
|
|
OS: ubuntu-22.04,
|
|
TOOLCHAIN: stable,
|
|
TARGET: aarch64-unknown-linux-musl,
|
|
NPM_PUBLISH: false,
|
|
PYPI_PUBLISH: true,
|
|
}
|
|
- {
|
|
NAME: win32-x64-mingw,
|
|
OS: windows-2022,
|
|
TOOLCHAIN: stable,
|
|
TARGET: x86_64-pc-windows-gnu,
|
|
NPM_PUBLISH: false,
|
|
PYPI_PUBLISH: true,
|
|
}
|
|
- {
|
|
NAME: win32-x64-msvc,
|
|
OS: windows-2022,
|
|
TOOLCHAIN: stable,
|
|
TARGET: x86_64-pc-windows-msvc,
|
|
NPM_PUBLISH: true,
|
|
PYPI_PUBLISH: true,
|
|
}
|
|
- {
|
|
NAME: win32-x86-msvc,
|
|
OS: windows-2022,
|
|
TOOLCHAIN: stable,
|
|
TARGET: i686-pc-windows-msvc,
|
|
NPM_PUBLISH: false,
|
|
PYPI_PUBLISH: true,
|
|
}
|
|
- {
|
|
NAME: win32-arm64-msvc,
|
|
OS: windows-2022,
|
|
TOOLCHAIN: stable,
|
|
TARGET: aarch64-pc-windows-msvc,
|
|
NPM_PUBLISH: true,
|
|
PYPI_PUBLISH: false,
|
|
}
|
|
- {
|
|
NAME: darwin-x64,
|
|
OS: macos-12,
|
|
TOOLCHAIN: stable,
|
|
TARGET: x86_64-apple-darwin,
|
|
NPM_PUBLISH: true,
|
|
PYPI_PUBLISH: true,
|
|
}
|
|
- {
|
|
NAME: darwin-arm64,
|
|
OS: macos-12,
|
|
TOOLCHAIN: stable,
|
|
TARGET: aarch64-apple-darwin,
|
|
NPM_PUBLISH: true,
|
|
PYPI_PUBLISH: true,
|
|
}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Set the release version
|
|
shell: bash
|
|
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
|
|
- name: Install dependencies
|
|
shell: bash
|
|
run: |
|
|
if [[ "${{ matrix.build.NAME }}" = *"-musl" ]]; then
|
|
sudo apt-get update
|
|
sudo apt-get install -y --no-install-recommends \
|
|
--allow-unauthenticated musl-tools
|
|
fi
|
|
- name: Install Rust toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: ${{ matrix.build.TOOLCHAIN }}
|
|
target: ${{ matrix.build.TARGET }}
|
|
override: true
|
|
- name: Build (linux/macos)
|
|
if: matrix.build.OS != 'windows-2022'
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
use-cross: true
|
|
command: build
|
|
args: --release --locked --target ${{ matrix.build.TARGET }}
|
|
- name: Build (windows)
|
|
if: matrix.build.OS == 'windows-2022'
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
args: --no-default-features --release --locked --target ${{ matrix.build.TARGET }}
|
|
- name: Prepare release assets
|
|
shell: bash
|
|
run: |
|
|
mkdir -p release/{man,completions}
|
|
cp {LICENSE,README.md,CHANGELOG.md} release/
|
|
OUT_DIR=release/completions/ cargo run --release --bin git-cliff-completions
|
|
OUT_DIR=release/man/ cargo run --release --bin git-cliff-mangen
|
|
for bin in 'git-cliff' 'git-cliff-completions' 'git-cliff-mangen'; do
|
|
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
|
|
bin="${bin}.exe"
|
|
fi
|
|
cp "target/${{ matrix.build.TARGET }}/release/${bin}" release/
|
|
done
|
|
mv release/ git-cliff-${{ env.RELEASE_VERSION }}/
|
|
- name: Create release artifacts
|
|
shell: bash
|
|
run: |
|
|
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
|
|
7z a -tzip "git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.zip" \
|
|
git-cliff-${{ env.RELEASE_VERSION }}/
|
|
else
|
|
tar -czvf git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \
|
|
git-cliff-${{ env.RELEASE_VERSION }}/
|
|
shasum -a 512 git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \
|
|
> git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz.sha512
|
|
fi
|
|
- name: Sign the release
|
|
if: matrix.build.OS == 'ubuntu-22.04' || matrix.build.OS == 'macos-12'
|
|
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.build.TARGET }}.tar.gz
|
|
- name: Publish to GitHub
|
|
if: ${{ !contains(env.RELEASE_VERSION, 'alpha') && !contains(env.RELEASE_VERSION, 'beta') && !contains(env.RELEASE_VERSION, 'rc') }}
|
|
uses: svenstaro/upload-release-action@v2
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
file: git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}*
|
|
file_glob: true
|
|
overwrite: true
|
|
tag: ${{ github.ref }}
|
|
release_name: "Release v${{ env.RELEASE_VERSION }}"
|
|
body: "${{ needs.generate-changelog.outputs.release_body }}"
|
|
- name: Publish to GitHub (pre-release)
|
|
if: ${{ contains(env.RELEASE_VERSION, 'alpha') || contains(env.RELEASE_VERSION, 'beta') || contains(env.RELEASE_VERSION, 'rc') }}
|
|
uses: svenstaro/upload-release-action@v2
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
file: git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}*
|
|
file_glob: true
|
|
overwrite: true
|
|
tag: ${{ github.ref }}
|
|
release_name: "Pre-release v${{ env.RELEASE_VERSION }}"
|
|
prerelease: true
|
|
- name: Install node
|
|
if: matrix.build.NPM_PUBLISH == true
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: "16"
|
|
registry-url: "https://registry.npmjs.org"
|
|
- name: Publish to NPM
|
|
if: matrix.build.NPM_PUBLISH == true
|
|
shell: bash
|
|
run: |
|
|
cd npm
|
|
bin="git-cliff"
|
|
node_os=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f1)
|
|
export node_os
|
|
node_arch=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f2)
|
|
export node_arch
|
|
export version="${{ env.RELEASE_VERSION }}"
|
|
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
|
|
export node_pkg="${bin}-windows-${node_arch}"
|
|
else
|
|
export node_pkg="${bin}-${node_os}-${node_arch}"
|
|
fi
|
|
mkdir -p "${node_pkg}/bin"
|
|
envsubst < package.json.tmpl > "${node_pkg}/package.json"
|
|
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
|
|
bin="${bin}.exe"
|
|
fi
|
|
cp "../target/${{ matrix.build.TARGET }}/release/${bin}" "${node_pkg}/bin"
|
|
cp ../README.md "${node_pkg}"
|
|
cd "${node_pkg}"
|
|
npm publish --access public
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
- name: Build Python wheels (linux)
|
|
if: matrix.build.PYPI_PUBLISH == true && startsWith(matrix.build.NAME, 'linux')
|
|
uses: PyO3/maturin-action@v1
|
|
with:
|
|
working-directory: pypi
|
|
target: ${{ matrix.build.TARGET }}
|
|
args: --release --sdist --out wheels
|
|
sccache: "true"
|
|
manylinux: auto
|
|
- name: Build Python wheels (macos & windows)
|
|
if: |
|
|
matrix.build.PYPI_PUBLISH == true &&
|
|
(startsWith(matrix.build.OS, 'macos') || startsWith(matrix.build.OS, 'windows'))
|
|
uses: PyO3/maturin-action@v1
|
|
with:
|
|
working-directory: pypi
|
|
target: ${{ matrix.build.TARGET }}
|
|
args: --release --sdist --out wheels
|
|
sccache: "true"
|
|
- name: Build Python wheels (musl)
|
|
if: matrix.build.PYPI_PUBLISH == true && endsWith(matrix.build.OS, 'musl')
|
|
uses: PyO3/maturin-action@v1
|
|
with:
|
|
working-directory: pypi
|
|
target: ${{ matrix.build.TARGET }}
|
|
args: --release --sdist --out wheels
|
|
sccache: "true"
|
|
manylinux: musllinux_1_2
|
|
- name: Upload Python wheels
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
working-directory: pypi
|
|
name: wheels
|
|
path: pypi/wheels
|
|
|
|
publish-npm:
|
|
name: Publish the base package to NPM
|
|
needs: publish-binaries
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Install node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: "16"
|
|
registry-url: "https://registry.npmjs.org"
|
|
- name: Publish the package
|
|
shell: bash
|
|
run: |
|
|
cd npm/git-cliff
|
|
yarn install
|
|
yarn build
|
|
cp ../../README.md .
|
|
npm publish --access public
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
publish-pypi:
|
|
name: Publish PyPI package
|
|
runs-on: ubuntu-22.04
|
|
needs: publish-binaries
|
|
steps:
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
path: pypi/wheels
|
|
name: wheels
|
|
- name: Publish to PyPI
|
|
uses: PyO3/maturin-action@v1
|
|
env:
|
|
MATURIN_PYPI_TOKEN: ${{ vars.USE_TESTPYPI == 'true' && secrets.TESTPYPI_API_TOKEN || secrets.PYPI_API_TOKEN }}
|
|
MATURIN_REPOSITORY: ${{ vars.USE_TESTPYPI == 'true' && 'testpypi' || 'pypi' }}
|
|
with:
|
|
command: upload
|
|
args: --skip-existing pypi/wheels/*
|
|
|
|
publish-deb:
|
|
name: Publish Debian package
|
|
needs: generate-changelog
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Set the release version
|
|
shell: bash
|
|
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: x86_64-unknown-linux-gnu
|
|
- name: Install cargo-deb
|
|
run: cargo install cargo-deb
|
|
- name: Build Debian package
|
|
run: |
|
|
# https://github.com/kornelski/cargo-deb/pull/62
|
|
sed "/readme = (.*)/d" -E -i git-cliff/Cargo.toml
|
|
cargo-deb --strip --manifest-path git-cliff/Cargo.toml -v -o git-cliff-${{ env.RELEASE_VERSION }}.deb
|
|
- name: Sign the package
|
|
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 }}.deb
|
|
- name: Upload the release
|
|
if: ${{ !contains(env.RELEASE_VERSION, 'alpha') && !contains(env.RELEASE_VERSION, 'beta') && !contains(env.RELEASE_VERSION, 'rc') }}
|
|
uses: svenstaro/upload-release-action@v2
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
file: git-cliff-${{ env.RELEASE_VERSION }}.deb
|
|
tag: ${{ github.ref }}
|
|
release_name: "Release v${{ env.RELEASE_VERSION }}"
|
|
body: "${{ needs.generate-changelog.outputs.release_body }}"
|
|
- name: Upload the pre-release
|
|
if: ${{ contains(env.RELEASE_VERSION, 'alpha') || contains(env.RELEASE_VERSION, 'beta') || contains(env.RELEASE_VERSION, 'rc') }}
|
|
uses: svenstaro/upload-release-action@v2
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
file: git-cliff-${{ env.RELEASE_VERSION }}.deb
|
|
tag: ${{ github.ref }}
|
|
release_name: "Pre-release v${{ env.RELEASE_VERSION }}"
|
|
prerelease: true
|
|
|
|
publish-crates-io:
|
|
name: Publish on crates.io
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Set the release version
|
|
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: x86_64-unknown-linux-gnu
|
|
- name: Prepare for the crates.io release
|
|
run: |
|
|
mkdir git-cliff-core/config/
|
|
cp config/cliff.toml git-cliff-core/config/
|
|
sed -i 's|"../config/"|"config/"|' git-cliff-core/src/embed.rs
|
|
- name: Publish the library
|
|
run: |
|
|
cargo publish --allow-dirty --manifest-path git-cliff-core/Cargo.toml \
|
|
--locked --token ${{ secrets.CARGO_TOKEN }}
|
|
- name: Wait for library to update
|
|
shell: bash
|
|
run: |
|
|
crate_status="https://raw.githubusercontent.com/rust-lang/crates.io-index/master/gi/t-/git-cliff-core"
|
|
until curl -s "$crate_status" | grep -q '"vers":"${{ env.RELEASE_VERSION }}"'; do sleep 5; done;
|
|
- name: Publish the binary
|
|
run: |
|
|
cargo publish --allow-dirty --manifest-path git-cliff/Cargo.toml \
|
|
--locked --token ${{ secrets.CARGO_TOKEN }}
|