From 6508b0f0d381f0a7d2b982ebebe0739e39273c02 Mon Sep 17 00:00:00 2001 From: msalib Date: Thu, 30 Dec 2021 18:31:52 -0500 Subject: [PATCH] feat: you know, CI fun (#10) --- .github/workflows/CI.yml | 3 + .github/workflows/Release.yml | 158 ++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 .github/workflows/Release.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3312ffa..9e43a93 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -26,6 +26,7 @@ jobs: # anyway so there's no point to run tests a third time. BuildLinux: runs-on: ubuntu-latest + if: "!startsWith(github.ref, 'refs/tags/')" steps: - uses: actions/checkout@v2 @@ -63,6 +64,7 @@ jobs: BuildWindows: runs-on: windows-latest + if: "!startsWith(github.ref, 'refs/tags/')" steps: - uses: actions/checkout@v2 @@ -92,6 +94,7 @@ jobs: BuildMacOS: runs-on: macos-latest + if: "!startsWith(github.ref, 'refs/tags/')" steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml new file mode 100644 index 0000000..2a681f3 --- /dev/null +++ b/.github/workflows/Release.yml @@ -0,0 +1,158 @@ +name: Release + + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + CARGO_TERM_COLOR: always + # https://matklad.github.io/2021/09/04/fast-rust-builds.html + # indicates that non-incremental builds improve CI performance. + CARGO_INCREMENTAL: 0 + # Since we're not shipping any build artifacts, turning off debug + # symbols will speed things up without hurting anything. + RUSTFLAGS: '-C debuginfo=0' + +# All the build jobs except linux specify no-sdist so we only build it +# once. The linux job is also special since that's the only one in +# which we run clippy. + +jobs: + # This only runs when we push to main. Instead of running tests, we + # bump the version and make a tag. + BumpVersion: + runs-on: ubuntu-latest + if: "startsWith(github.ref, 'refs/tags/')" + #if: github.ref == 'refs/heads/main' && github.event_name == 'push' + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + # - run: git config user.name "GitHub actions" + # - run: git config user.email "github-actions@users.noreply.github.com" + # - run: python3 -m pip install --user python-semantic-release + # - run: python -m semantic_release version -v DEBUG -D commit_author="github-actions " + + - name: Python Semantic Release + uses: relekang/python-semantic-release@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - run: git push + + # These Build* jobs run all the time except when we're pushing to + # main; we've already run tests in the PR and after we increment the + # semantic release number, we're going to run tests on that commit + # anyway so there's no point to run tests a third time. + BuildLinux: + runs-on: ubuntu-latest + needs: [ BumpVersion ] + steps: + - uses: actions/checkout@v2 + + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features + + # Looks like cargo-bloat-action won't be working for us anytime + # soon unfortunately.... + # - name: cargo bloat + # uses: orf/cargo-bloat-action@v1 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + + - name: maturin build + uses: messense/maturin-action@v1 + with: + manylinux: manylinux2014 + command: build + args: --release --strip -o dist + + - name: install locally built wheel + run: pip install --user --find-links=dist geo_rasterize --force-reinstall + + - name: run doctests + run: python -m doctest -v README.md + + - name: Upload wheels + uses: actions/upload-artifact@v2 + with: + name: wheels + path: dist + retention-days: 2 + + BuildWindows: + runs-on: windows-latest + needs: [ BumpVersion ] + steps: + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - uses: messense/maturin-action@v1 + with: + command: build + args: --release --strip --no-sdist -o dist + + - name: install locally built wheel + run: pip install --user --find-links=dist geo_rasterize --force-reinstall + + - name: run doctests + run: python -m doctest -v README.md + + - name: Upload wheels + uses: actions/upload-artifact@v2 + with: + name: wheels + path: dist + retention-days: 2 + + BuildMacOS: + runs-on: macos-latest + needs: [ BumpVersion ] + steps: + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - uses: messense/maturin-action@v1 + with: + command: build + args: --release --strip --no-sdist -o dist --universal2 + + - name: Upload wheels + uses: actions/upload-artifact@v2 + with: + name: wheels + path: dist + retention-days: 2 + + # We've got a new version! `Build` will run and after it finishes we + # can publish! + Publish: + runs-on: ubuntu-latest + needs: [ BuildLinux, BuildWindows, BuildMacOS ] + steps: + - uses: actions/download-artifact@v2 + with: + name: wheels + - name: Publish to PyPI + uses: messense/maturin-action@v1 + env: + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + with: + command: upload + args: --repository-url=https://test.pypi.org/legacy/ --username=msalib --skip-existing *