Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
30 changes: 3 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]
workflow_dispatch:

defaults:
Expand All @@ -22,6 +20,7 @@ jobs:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@v2
with: { tool: 'just' }
- run: just env-info
- uses: Swatinem/rust-cache@v2
- run: just ci-lint
test:
Expand Down Expand Up @@ -56,6 +55,7 @@ jobs:
- uses: taiki-e/install-action@v2
with: { tool: 'just' }
- uses: Swatinem/rust-cache@v2
- run: just env-info
- name: Install linux dependencies
if: startsWith(matrix.runs-on, 'ubuntu')
run: |
Expand Down Expand Up @@ -117,37 +117,13 @@ jobs:
# toolchain: ${{ env.NIGHTLY }}
# components: miri
# - run: just test-miri ${{ matrix.backend }}
release:
needs: [test, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@v2
with: { tool: 'just' }
- if: github.event_name == 'release'
name: Ensure this crate has not yet been published (on release)
run: just check-if-published
# - name: Check semver
# uses: obi1kenobi/cargo-semver-checks-action@v2
#######################################################################################################

#######################################################################################################
## Publish to crates.io
##
- if: github.event_name == 'push'
run: just test-publishing
- if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')
name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

# This final step is needed to mark the whole workflow as successful
# Don't change its name - it is used by the merge protection rules
done:
name: CI Finished
runs-on: ubuntu-latest
needs: [ release ]
needs: [test, lint]
if: always()
steps:
- name: Result of the needed steps
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release-plz

permissions:
pull-requests: write
contents: write

on:
push:
branches: [main]

jobs:
# Release unpublished packages.
release-plz-release:
name: Release-plz release
if: ${{ github.repository_owner == 'maplibre' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: dtolnay/rust-toolchain@stable
- uses: release-plz/action@v0.5
with: { command: release }
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

# Create a PR with the new versions and changelog, preparing the next release.
release-plz-pr:
name: Release-plz PR
if: ${{ github.repository_owner == 'nyurik' }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
concurrency:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: dtolnay/rust-toolchain@stable
- uses: release-plz/action@v0.5
with: { command: release-pr }
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63 changes: 46 additions & 17 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#!/usr/bin/env just --justfile

main_crate := 'maplibre_native'
features_flag := '--all-features'

# if running in CI, treat warnings as errors by setting RUSTFLAGS and RUSTDOCFLAGS to '-D warnings' unless they are already set
# Use `CI=true just ci-test` to run the same tests as in GitHub CI.
# Use `just env-info` to see the current values of RUSTFLAGS and RUSTDOCFLAGS
ci_mode := if env('CI', '') != '' {'1'} else {''}
export RUSTFLAGS := env('RUSTFLAGS', if ci_mode == '1' {'-D warnings'} else {''})
export RUSTDOCFLAGS := env('RUSTDOCFLAGS', if ci_mode == '1' {'-D warnings'} else {''})
export RUST_BACKTRACE := env('RUST_BACKTRACE', if ci_mode == '1' {'1'} else {''})

@_default:
just --list
{{just_executable()}} --list

# Build the library
build backend="vulkan":
Expand All @@ -11,22 +22,6 @@ build backend="vulkan":
check:
RUSTFLAGS='-D warnings' cargo check --workspace --all-targets

# Verify that the current version of the crate is not the same as the one published on crates.io
check-if-published: (assert "jq")
#!/usr/bin/env bash
LOCAL_VERSION="$(cargo metadata --format-version 1 | jq -r '.resolve.root | sub(".*@"; "")')"
echo "Detected crate version: $LOCAL_VERSION"
CRATE_NAME="$(cargo metadata --format-version 1 | jq -r '.resolve.root | sub(".*#"; "") | sub("@.*"; "")')"
echo "Detected crate name: $CRATE_NAME"
PUBLISHED_VERSION="$(cargo search ${CRATE_NAME} | grep "^${CRATE_NAME} =" | sed -E 's/.* = "(.*)".*/\1/')"
echo "Published crate version: $PUBLISHED_VERSION"
if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then
echo "ERROR: The current crate version has already been published."
exit 1
else
echo "The current crate version has not yet been published."
fi

# Lint the project
ci-lint: rust-info test-fmt clippy

Expand All @@ -46,6 +41,17 @@ clippy:
docs:
cargo doc --no-deps --open

# Print environment info
env-info:
@echo "Running {{if ci_mode == '1' {'in CI mode'} else {'in dev mode'} }} on {{os()}} / {{arch()}}"
{{just_executable()}} --version
rustc --version
cargo --version
rustup --version
@echo "RUSTFLAGS='$RUSTFLAGS'"
@echo "RUSTDOCFLAGS='$RUSTDOCFLAGS'"
@echo "RUST_BACKTRACE='$RUST_BACKTRACE'"

# Reformat all code `cargo fmt`. If nightly is available, use it for better results
fmt:
#!/usr/bin/env bash
Expand All @@ -62,6 +68,14 @@ fmt:
msrv:
cargo msrv find --write-msrv --ignore-lockfile

# Run cargo-release
release *args='': (cargo-install 'release-plz')
release-plz {{args}}

# Check semver compatibility with prior published version. Install it with `cargo install cargo-semver-checks`
semver *args: (cargo-install 'cargo-semver-checks')
cargo semver-checks {{features_flag}} {{args}}

package:
cargo package

Expand Down Expand Up @@ -171,3 +185,18 @@ assert $COMMAND:
echo "Command '{{COMMAND}}' could not be found. Please make sure it has been installed on your computer." ;\
exit 1 ;\
fi

# Check if a certain Cargo command is installed, and install it if needed
[private]
cargo-install $COMMAND $INSTALL_CMD='' *args='':
#!/usr/bin/env bash
set -euo pipefail
if ! command -v $COMMAND > /dev/null; then
if ! command -v cargo-binstall > /dev/null; then
echo "$COMMAND could not be found. Installing it with cargo install ${INSTALL_CMD:-$COMMAND} --locked {{args}}"
cargo install ${INSTALL_CMD:-$COMMAND} --locked {{args}}
else
echo "$COMMAND could not be found. Installing it with cargo binstall ${INSTALL_CMD:-$COMMAND} --locked {{args}}"
cargo binstall ${INSTALL_CMD:-$COMMAND} --locked {{args}}
fi
fi
3 changes: 3 additions & 0 deletions release-plz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
git_release_name = "v{{ version }}"
git_tag_name = "v{{ version }}"