Generate Changelog #4
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: Generate Changelog | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
generate-changelog: | |
name: Generate Changelog | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set Up Git | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
- name: Generate Changelog with git-cliff | |
uses: orhun/git-cliff-action@main | |
id: git-cliff | |
with: | |
config: cliff.toml | |
args: -vv --latest --no-exec --github-repo ${{ github.repository }} | |
- name: Display Generated Changelog | |
run: echo "${{ steps.git-cliff.outputs.content }}" | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: "Release ${{ github.ref }}" | |
body: ${{ steps.git-cliff.outputs.content }} | |
draft: false | |
prerelease: false | |
token: ${{ secrets.GITHUB_TOKEN }} | |
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: false, | |
} | |
- { | |
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-14, | |
TOOLCHAIN: stable, | |
TARGET: x86_64-apple-darwin, | |
NPM_PUBLISH: true, | |
PYPI_PUBLISH: true, | |
} | |
- { | |
NAME: darwin-arm64, | |
OS: macos-14, | |
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 --target ${{ matrix.build.TARGET }} | |
- name: Build (windows) | |
if: matrix.build.OS == 'windows-2022' | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --target ${{ matrix.build.TARGET }} # --no-default-features | |
- name: Prepare release assets | |
shell: bash | |
run: | | |
mkdir -p release/{man,completions} | |
cp {LICENSE,LREADME.md,CHANGELOG.md} release/ | |
OUT_DIR=release/completions/ cargo run --release --bin smd-completions | |
OUT_DIR=release/man/ cargo run --release --bin smd-mangen | |
for bin in 'smd' 'smd-completions' 'smd-mangen'; do | |
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then | |
bin="${bin}.exe" | |
fi | |
cp "target/${{ matrix.build.TARGET }}/release/${bin}" release/ | |
done | |
mv release/ smd-${{ env.RELEASE_VERSION }}/ | |
- name: Create release artifacts | |
shell: bash | |
run: | | |
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then | |
7z a -tzip "smd-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.zip" \ | |
smd-${{ env.RELEASE_VERSION }}/ | |
else | |
tar -czvf smd-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \ | |
smd-${{ env.RELEASE_VERSION }}/ | |
shasum -a 512 smd-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \ | |
> smd-${{ 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-14' | |
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 \ | |
smd-${{ 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: smd-${{ 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: smd-${{ 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: 18 | |
registry-url: "https://registry.npmjs.org" | |
- name: Publish to NPM | |
if: matrix.build.NPM_PUBLISH == true | |
shell: bash | |
run: | | |
cd npm | |
bin="smd" | |
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 | |
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: 18 | |
registry-url: "https://registry.npmjs.org" | |
- name: Publish the package | |
shell: bash | |
working-directory: npm/smd | |
run: | | |
yarn config set npmAuthToken ${NODE_AUTH_TOKEN} | |
yarn config set npmPublishRegistry "https://registry.npmjs.org" | |
yarn install | |
yarn build | |
cp ../../README.md . | |
cp ../../CHANGELOG.md . | |
if [ ${{ contains(github.ref, '-') }} = "true" ]; then | |
yarn npm publish --tag rc | |
else | |
yarn npm publish | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
YARN_ENABLE_IMMUTABLE_INSTALLS: false | |
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 smd/Cargo.toml | |
cargo build --release -p smd | |
mkdir man/ | |
OUT_DIR=man cargo run --bin smd-mangen | |
mkdir completions | |
OUT_DIR=completions cargo run --bin smd-completions | |
cargo-deb --deb-revision="" --strip -p smd -v -o smd-${{ 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 \ | |
smd-${{ 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: smd-${{ 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: smdcliff-${{ 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 -p smd | |
mkdir man/ | |
OUT_DIR=man cargo run --bin smd-mangen | |
mkdir completions | |
OUT_DIR=completions cargo run --bin smd-completions | |
cargo generate-rpm -p smd -o smd-${{ 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 \ | |
smd-${{ 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: smd-${{ 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: smd-${{ 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: Publish the libraries | |
run: | | |
cargo publish --allow-dirty --manifest-path smd-core/Cargo.toml \ | |
--token ${{ secrets.CARGO_TOKEN }} | |
cargo publish --allow-dirty --manifest-path gfm/Cargo.toml \ | |
--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-/smd-core" | |
until curl -s "$crate_status" | grep -q '"vers":"${{ env.RELEASE_VERSION }}"'; do sleep 5; done; | |
crate_status="https://raw.githubusercontent.com/rust-lang/crates.io-index/master/gi/t-/gfm" | |
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 smd/Cargo.toml \ | |
--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: smd | |
formula-path: Formula/g/smd.rb | |
env: | |
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_COMMITTER_TOKEN }} |