Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 237 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
name: Release

on:
push:
tags: ["v*"]
workflow_dispatch:

permissions:
contents: read

jobs:
build:
name: Build ${{ matrix.platform.target }}
strategy:
fail-fast: false
matrix:
platform:
- target: x86_64-apple-darwin
os: macos-latest
python-architecture: x64
archive: diffenator3-x86_64-apple-darwin.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
python-architecture: x64
archive: diffenator3-x86_64-pc-windows-msvc.zip
- target: i686-pc-windows-msvc
os: windows-latest
python-architecture: x86
archive: diffenator3-i686-pc-windows-msvc.zip
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
architecture: ${{ matrix.platform.python-architecture }}

- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}

- name: Install protoc for google-fonts-languages
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

# Install gnu-tar because BSD tar is buggy
# https://github.com/actions/cache/issues/403
- name: Install GNU tar (macOS)
if: matrix.platform.os == 'macos-latest'
run: |
brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH

- name: Build wheel (macOS universal2) and sdist
if: matrix.platform.target == 'x86_64-apple-darwin'
uses: PyO3/maturin-action@v1
with:
target: universal2-apple-darwin
args: --release -o dist --sdist

- name: Build wheel (without sdist)
if: matrix.platform.target != 'x86_64-apple-darwin'
uses: PyO3/maturin-action@v1
with:
target: ${{matrix.platform.target}}
args: --release -o dist

- name: Install wheel
shell: bash
run: |
pip install --no-index --find-links dist/ --force-reinstall diffenator3
which diffenator3
diffenator3 --version

- name: Check sdist metadata
if: matrix.platform.target == 'x86_64-apple-darwin'
run: pipx run twine check dist/*.tar.gz

- name: Archive binary
if: matrix.platform.os != 'windows-latest'
run: |
cd target/${{ matrix.platform.target }}/release
tar czvf ../../../${{ matrix.platform.archive }} diffenator3 diff3proof
cd -

- name: Archive binary (windows)
if: matrix.platform.os == 'windows-latest'
run: |
cd target/${{ matrix.platform.target }}/release
7z a ../../../${{ matrix.platform.archive }} diffenator3.exe diff3proof.exe
cd -

- name: Archive binary (macOS aarch64)
if: matrix.platform.os == 'macos-latest'
run: |
cd target/aarch64-apple-darwin/release
tar czvf ../../../diffenator3-aarch64-apple-darwin.tar.gz diffenator3 diff3proof
cd -

- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform.target }}
path: dist

- name: Upload binary artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.platform.target }}
path: |
*.tar.gz
*.zip

build_linux:
name: Build ${{ matrix.platform.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- target: "x86_64-unknown-linux-musl"
image_tag: "x86_64-musl"
compatibility: "manylinux2010 musllinux_1_1"
- target: "aarch64-unknown-linux-musl"
image_tag: "aarch64-musl"
compatibility: "manylinux2014 musllinux_1_1"
container:
image: docker://ghcr.io/rust-cross/rust-musl-cross:${{ matrix.platform.image_tag }}
steps:
- uses: actions/checkout@v3

- name: Build Wheels
uses: PyO3/maturin-action@main
with:
target: ${{ matrix.platform.target }}
manylinux: ${{ matrix.platform.compatibility }}
container: off
args: --release -o dist

- name: Install x86_64 wheel
if: startsWith(matrix.platform.target, 'x86_64')
run: |
/usr/bin/python3 -m pip install --no-index --find-links dist/ --force-reinstall diffenator3
which diffenator3
diffenator3 --version

- name: Archive binary
run: tar czvf target/release/diffenator3-${{ matrix.platform.target }}.tar.gz -C target/${{ matrix.platform.target }}/release diffenator3 diff3proof

- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform.target }}
path: dist

- name: Upload binary artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.platform.target }}
path: target/release/diffenator3-${{ matrix.platform.target }}.tar.gz

release-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/v')
needs: [build, build_linux]
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist

- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true

release-github:
permissions:
contents: write
name: Publish to GitHub releases
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: [build, build_linux]
steps:
- uses: actions/download-artifact@v4
with:
pattern: binaries-*
merge-multiple: true

- uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: wheels

- name: Generate requirements.txt with SHA256 hashes
run: |
pipx install pip-tools
pipx runpip pip-tools install 'pip==25.0.1'
echo diffenator3 | pip-compile - --no-index --find-links wheels/ --no-emit-find-links --generate-hashes --pip-args '--only-binary=:all:' --no-annotate --no-header --output-file requirements.txt

- name: Compute checksums of release assets
run: |
sha256sum *.tar.gz *.zip requirements.txt > checksums.txt

- name: Detect if tag is a pre-release
id: before_release
env:
PRERELEASE_TAG_PATTERN: "v[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+([ab]|rc)[[:digit:]]+"
run: |
TAG_NAME="${GITHUB_REF##*/}"
if egrep -q "$PRERELEASE_TAG_PATTERN" <<< "$TAG_NAME"; then
echo "Tag ${TAG_NAME} contains a pre-release suffix"
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "Tag ${TAG_NAME} does not contain a pre-release suffix"
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
fi
echo "release_title=${TAG_NAME#v}" >> "$GITHUB_OUTPUT"

- name: Release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.before_release.outputs.release_title }}
files: |
*.tar.gz
*.zip
checksums.txt
requirements.txt
prerelease: ${{ steps.before_release.outputs.is_prerelease }}
generate_release_notes: true
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions diffenator3-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ license = "Apache-2.0"
name = "diffenator3"
path = "src/main.rs"

[[bin]]
name = "diff3proof"
path = "src/bin/diff3proof.rs"
[lib]
crate-type = ["cdylib", "rlib"]
path = "src/lib.rs"
Expand All @@ -34,6 +37,11 @@ colored = "2.1.0"
clap = { version = "4.5.9", features = ["derive"] }
itertools = "0.13.0"
env_logger = "0.11"

# diff3proof dependencies
google-fonts-languages = "0"
tera = "1"
fancy-regex = "0.13"
log = { workspace = true }
shaperglot = { workspace = true }
tabled = "0.20.0"
Expand Down
Loading
Loading