chore(release): prepare for v2.1.0 #75
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 --no-exec --github-repo ${GITHUB_REPOSITORY} | |
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: false, | |
} | |
- { | |
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: --release --locked --target ${{ matrix.build.TARGET }} # --no-default-features | |
- name: Prepare release assets | |
shell: bash | |
run: | | |
mkdir -p release/{man,completions} | |
cp {LICENSE-MIT,LICENSE-APACHE,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(github.ref, '-') }} | |
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(github.ref, '-') }} | |
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@v4 | |
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" | |
# https://github.com/PyO3/maturin-action/issues/245 | |
manylinux: ${{ matrix.build.TARGET == 'aarch64-unknown-linux-gnu' && '2_28' || '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@v4 | |
with: | |
name: "wheels-${{ matrix.build.TARGET }}" | |
working-directory: pypi | |
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@v4 | |
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@v4 | |
with: | |
path: pypi/wheels | |
pattern: wheels-* | |
merge-multiple: true | |
- 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 build --release --locked -p git-cliff | |
mkdir man/ | |
OUT_DIR=man cargo run --bin git-cliff-mangen | |
mkdir completions | |
OUT_DIR=completions cargo run --bin git-cliff-completions | |
cargo-deb --deb-revision="" --strip -p git-cliff -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(github.ref, '-') }} | |
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(github.ref, '-') }} | |
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-rpm: | |
name: Publish RPM 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-generate-rpm | |
run: cargo install cargo-generate-rpm | |
- name: Build RPM package | |
run: | | |
cargo build --release --locked -p git-cliff | |
mkdir man/ | |
OUT_DIR=man cargo run --bin git-cliff-mangen | |
mkdir completions | |
OUT_DIR=completions cargo run --bin git-cliff-completions | |
cargo generate-rpm -p git-cliff -o git-cliff-${{ env.RELEASE_VERSION }}.x86_64.rpm | |
- 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 }}.x86_64.rpm | |
- name: Upload the release | |
if: ${{ !contains(github.ref, '-') }} | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: git-cliff-${{ env.RELEASE_VERSION }}.x86_64.rpm | |
tag: ${{ github.ref }} | |
release_name: "Release v${{ env.RELEASE_VERSION }}" | |
body: "${{ needs.generate-changelog.outputs.release_body }}" | |
- name: Upload the pre-release | |
if: ${{ contains(github.ref, '-') }} | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: git-cliff-${{ env.RELEASE_VERSION }}.x86_64.rpm | |
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 | |
mkdir git-cliff-core/examples/ | |
cp -r examples git-cliff-core | |
sed -i 's|"../examples/"|"examples/"|' 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 }} | |
publish-homebrew: | |
name: Publish Homebrew formula | |
if: ${{ !contains(github.ref, '-') }} | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
steps: | |
- name: Bump formula | |
uses: mislav/bump-homebrew-formula-action@v3 | |
with: | |
formula-name: git-cliff | |
formula-path: Formula/g/git-cliff.rb | |
env: | |
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_COMMITTER_TOKEN }} |