Skip to content

Commit

Permalink
feat: you know, CI fun (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
msalib authored Dec 30, 2021
1 parent a8d915f commit 6508b0f
Show file tree
Hide file tree
Showing 2 changed files with 161 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -63,6 +64,7 @@ jobs:

BuildWindows:
runs-on: windows-latest
if: "!startsWith(github.ref, 'refs/tags/')"
steps:
- uses: actions/checkout@v2

Expand Down Expand Up @@ -92,6 +94,7 @@ jobs:

BuildMacOS:
runs-on: macos-latest
if: "!startsWith(github.ref, 'refs/tags/')"
steps:
- uses: actions/checkout@v2

Expand Down
158 changes: 158 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
# - run: python3 -m pip install --user python-semantic-release
# - run: python -m semantic_release version -v DEBUG -D commit_author="github-actions <[email protected]>"

- 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 *

0 comments on commit 6508b0f

Please sign in to comment.