modernize incl Eviction #120
This file contains hidden or 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 | |
| # Controls when the action will run. Triggers the workflow on push or pull | |
| # request events but only for the main branch. | |
| on: | |
| push: | |
| # Run on the main branch. | |
| branches: | |
| - main | |
| - ci | |
| tags: | |
| - "v*" | |
| pull_request: | |
| # Only run on pull requests against main. | |
| branches: [main] | |
| jobs: | |
| # We run this job first, to create any GitHub release that we might need. | |
| # Creating a release can only be done once, so we need to split it out from | |
| # other jobs. | |
| create_release: | |
| name: Create release (if needed) | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_version: ${{ steps.extract_release_version.outputs.release_version }} | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - uses: actions/checkout@v4 | |
| - name: Extract release version | |
| id: extract_release_version | |
| run: | | |
| release_version="$(echo '${{ github.ref }}' | sed 's,^.*/\([^/]*\)$,\1,; s,^v,,' )" | |
| echo Release version: $release_version | |
| echo "release_version=$release_version" >> $GITHUB_OUTPUT | |
| - name: Extract release body from CHANGELOG.md | |
| id: extract_release_body | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
| # Use `clparse` to parse `CHANGELOG.md` and extract release notes. | |
| run: | | |
| curl -sLO https://github.com/marcaddeo/clparse/releases/download/0.8.0/clparse-0.8.0-x86_64-unknown-linux-musl.tar.gz | |
| tar xzf clparse*.tar.gz | |
| sudo cp clparse /usr/local/bin | |
| rm -rf clparse* | |
| clparse -f json CHANGELOG.md | \ | |
| jq ".releases[] | select(.version == \"${{ steps.extract_release_version.outputs.release_version }}\") | { title: \"\", description: \"\", releases: [.] }" | \ | |
| clparse - | \ | |
| tail -n +3 > RELEASE_BODY.md | |
| - name: "Make release" | |
| id: create_release | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| name: "${{ steps.extract_release_version.outputs.release_version }}" | |
| body_path: RELEASE_BODY.md | |
| # We use a matrix to run our build on every supported platform. | |
| build: | |
| name: "Build" | |
| needs: | |
| - create_release | |
| strategy: | |
| matrix: | |
| # target: Official name of system to compile for. | |
| # host: Official name of system doing the compiling. | |
| # cargo: Should we use regular cargo, or the cross wrapper for cross-compiling? | |
| # os: GitHub CI OS image to use on runner. | |
| include: | |
| - target: x86_64-unknown-linux-musl | |
| host: x86_64-unknown-linux-musl | |
| cargo: cross | |
| os: ubuntu-latest | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Install libpostal dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y curl autotools-dev autoconf libtool pkg-config libicu-dev | |
| # Install libpostal from source since it's not in apt | |
| git clone https://github.com/openvenues/libpostal | |
| cd libpostal | |
| ./bootstrap.sh | |
| ./configure --prefix=/usr/local | |
| make -j4 | |
| sudo make install | |
| sudo ldconfig | |
| # Ensure proper permissions for libpostal data directory | |
| sudo mkdir -p /usr/local/share/libpostal | |
| sudo chmod 755 /usr/local/share/libpostal | |
| - uses: arduino/setup-protoc@v3 | |
| with: | |
| version: "25.1" | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| # We track latest stable Rust instead of hardcoding it because it | |
| # virtually never breaks old code. | |
| toolchain: stable | |
| components: rustfmt, clippy, rust-src | |
| targets: ${{ matrix.target }} | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install Just | |
| run: | | |
| version=1.13.0 | |
| basename=just-$version-${{ matrix.host }} | |
| curl -fLO https://github.com/casey/just/releases/download/$version/$basename.tar.gz | |
| tar xf $basename.tar.gz just | |
| mv just /usr/local/bin/ | |
| rm -rf $basename.tar.gz | |
| - name: Install cargo-deny | |
| run: | | |
| version=0.16.1 | |
| basename=cargo-deny-$version-${{ matrix.host }} | |
| curl -fLO https://github.com/EmbarkStudios/cargo-deny/releases/download/$version/$basename.tar.gz | |
| tar xf $basename.tar.gz | |
| mv $basename/cargo-deny /usr/local/bin/ | |
| rm -rf $basename $basename.tar.gz | |
| - name: Check source formatting, warnings, licences, security alerts & tests | |
| run: | | |
| just check | |
| - name: Install cargo cross (if needed) | |
| if: ${{ matrix.cargo == 'cross' }} | |
| # Note that this will not work for Rust programs using openssl or libpq. | |
| run: | | |
| version=v0.2.5 | |
| basename=cross-${{ matrix.host }} | |
| curl -fLO https://github.com/rust-embedded/cross/releases/download/$version/$basename.tar.gz | |
| tar xf $basename.tar.gz | |
| mv cross /usr/local/bin/ | |
| rm -rf $basename.tar.gz | |
| - name: Build binaries | |
| run: | | |
| ${{ matrix.cargo }} build --release --target ${{ matrix.target }} | |
| # If we have a code-signing identity, we could use it like this. | |
| # | |
| # - name: Sign binaries (if needed) | |
| # if: ${{ contains(matrix.target, 'apple') }} | |
| # run: | | |
| # codesign --force -s $YOUR_IDENTITY_HERE target/${{ matrix.target }}/release/geocode-csv | |
| - name: Build release | |
| id: build_release | |
| run: | | |
| release_file=geocode-csv_${{ needs.create_release.outputs.release_version }}_${{ matrix.target }}.zip | |
| zip -j $release_file target/${{ matrix.target }}/release/geocode-csv | |
| echo "release_file=$release_file" >> $GITHUB_OUTPUT | |
| - name: Upload Release Asset | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| files: ./${{ steps.build_release.outputs.release_file }} |