Update deps, update extension registration #117
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: CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [ published ] | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: taiki-e/install-action@v2 | |
with: { tool: just } | |
- uses: actions/checkout@v4 | |
- uses: Swatinem/rust-cache@v2 | |
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' | |
- run: just test | |
- name: Check semver | |
uses: obi1kenobi/cargo-semver-checks-action@v2 | |
- name: Get local and published versions | |
id: get-versions | |
run: | | |
echo "local_version=$(grep '^version =' Cargo.toml | sed -E 's/version = "([^"]*)".*/\1/')" >> $GITHUB_OUTPUT | |
CRATE_NAME=$(grep '^name =' Cargo.toml | head -1 | sed -E 's/name = "(.*)"/\1/') | |
PUBLISHED_VERSION=$(cargo search ${CRATE_NAME} | grep "^${CRATE_NAME} =" | sed -E 's/.* = "(.*)".*/\1/') | |
echo "published_version=${PUBLISHED_VERSION}" >> $GITHUB_OUTPUT | |
- name: Test that we haven't published current version yet | |
run: | | |
LOCAL_VERSION=${{ steps.get-versions.outputs.local_version }} | |
PUBLISHED_VERSION=${{ steps.get-versions.outputs.published_version }} | |
if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then | |
echo "The current crate version ($LOCAL_VERSION) has already been published." | |
exit 1 | |
else | |
echo "The current crate version ($LOCAL_VERSION) has not been published yet." | |
fi | |
msrv: | |
name: Test MSRV | |
runs-on: ubuntu-latest | |
steps: | |
- uses: taiki-e/install-action@v2 | |
with: { tool: just } | |
- uses: actions/checkout@v4 | |
- uses: Swatinem/rust-cache@v2 | |
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' | |
- name: Read crate metadata | |
id: metadata | |
run: echo "rust-version=$(sed -ne 's/rust-version *= *\"\(.*\)\"/\1/p' Cargo.toml)" >> $GITHUB_OUTPUT | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ steps.metadata.outputs.rust-version }} | |
components: clippy,rustfmt | |
- run: just test | |
build: | |
name: Build ${{ matrix.target }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: aarch64-apple-darwin | |
file: libsqlite_hashes.dylib | |
download: 'https://www.sqlite.org/2023/sqlite-tools-osx-x64-3440200.zip' | |
os: macOS-latest | |
sqlite3: ./sqlite3 | |
- target: x86_64-apple-darwin | |
file: libsqlite_hashes.dylib | |
download: 'https://www.sqlite.org/2023/sqlite-tools-osx-x64-3440200.zip' | |
os: macOS-latest | |
sqlite3: ./sqlite3 | |
- target: x86_64-pc-windows-msvc | |
file: sqlite_hashes.dll | |
download: 'https://www.sqlite.org/2023/sqlite-tools-win-x64-3440200.zip' | |
os: windows-latest | |
sqlite3: ./sqlite3.exe | |
- target: x86_64-unknown-linux-gnu | |
file: libsqlite_hashes.so | |
os: ubuntu-latest | |
sqlite3: sqlite3 | |
steps: | |
- uses: taiki-e/install-action@v2 | |
with: { tool: just } | |
- uses: actions/checkout@v4 | |
- uses: Swatinem/rust-cache@v2 | |
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' | |
- name: Download SQLite | |
if: matrix.download | |
uses: carlosperate/download-file-action@v2 | |
with: | |
file-url: '${{ matrix.download }}' | |
file-name: sqlite.zip | |
location: ./tmp-downloads | |
- name: Install SQLite | |
if: matrix.download | |
run: | | |
cd tmp-downloads | |
if [[ "${{ runner.os }}" == "Windows" ]]; then | |
7z x sqlite.zip | |
else | |
unzip sqlite.zip | |
chmod +x ${{ matrix.sqlite3 }} | |
fi | |
mv ${{ matrix.sqlite3 }} ../ | |
cd .. | |
rm -rf ./tmp-downloads | |
- name: SQLite Info | |
run: | | |
which ${{ matrix.sqlite3 }} | |
${{ matrix.sqlite3 }} --version | |
${{ matrix.sqlite3 }} <<EOF | |
.help | |
EOF | |
- name: Build | |
if: matrix.cross != 'true' | |
run: | | |
set -x | |
rustup target add "${{ matrix.target }}" | |
export RUSTFLAGS='-C strip=debuginfo' | |
just build-ext --release --target ${{ matrix.target }} | |
mkdir -p target/files | |
- name: Test ${{ matrix.target }} extension | |
if: matrix.target != 'aarch64-apple-darwin' | |
env: | |
EXTENSION_FILE: target/${{ matrix.target }}/release/examples/${{ matrix.file }} | |
SQLITE3_BIN: ${{ matrix.sqlite3 }} | |
run: ./tests/test-ext.sh | |
# - name: Test ${{ matrix.target }} extension | |
# if: matrix.target != 'aarch64-apple-darwin' | |
# run: just sqlite3=${{ matrix.sqlite3 }} extension_file=target/${{ matrix.target }}/release/examples/${{ matrix.file }} test-ext | |
- name: Package | |
run: | | |
pushd target/${{ matrix.target }}/release/examples | |
if [[ "${{ runner.os }}" == "Windows" ]]; then | |
7z a ../../../files/sqlite-hashes-${{ matrix.target }}.zip ${{ matrix.file }} | |
else | |
tar czvf ../../../files/sqlite-hashes-${{ matrix.target }}.tar.gz ${{ matrix.file }} | |
fi | |
popd | |
ls -lR target/files | |
- name: Publish | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true | |
files: 'target/files/*' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
cross-build: | |
name: Cross-build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: just,cross | |
- uses: actions/checkout@v4 | |
- uses: Swatinem/rust-cache@v2 | |
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' | |
- run: just cross-build-ext-aarch64 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/arm64 | |
- run: just cross-test-ext-aarch64 | |
- name: Package | |
run: | | |
mkdir -p target/files | |
tar czvf target/files/sqlite-hashes-aarch64-unknown-linux-gnu.tar.gz -C ./target/aarch64-unknown-linux-gnu/release/examples libsqlite_hashes.so | |
- run: ls -lR target/files | |
- name: Publish | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true | |
files: 'target/files/*' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish: | |
name: Publish to crates.io | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: [ test, msrv, build, cross-build ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Publish to crates.io | |
run: cargo publish | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |