diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d067389..622a66d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,10 +1,10 @@ -name: Lint +# name: Lint -on: [push] +# on: [push] -jobs: - black: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: psf/black@stable +# jobs: +# black: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# - uses: psf/black@stable diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..1b2929f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,69 @@ +name: Main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + pull_request: + branches: + - main + push: + branches: + - main + tags: + - "v*.*.*" + +env: + # Change this to invalidate existing cache. + PYTHONPATH: ./ + +jobs: + checks: + name: Python ${{ matrix.python }} - ${{ matrix.task.name }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: psf/black@stable + + release: + name: Release + runs-on: ubuntu-latest + needs: [checks] + # if: startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@v1 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install requirements + run: | + pip install --upgrade pip setuptools wheel "twine>=1.11.0" + + - name: Prepare environment + run: | + echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Download package distribution files + uses: actions/download-artifact@v3 + with: + name: package + path: dist + + - name: Publish package to PyPI + run: | + twine upload -u '${{ secrets.PYPI_USERNAME }}' -p '${{ secrets.PYPI_PASSWORD }}' dist/* + + - name: Publish GitHub release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # body_path: ${{ github.workspace }}-RELEASE_NOTES.md + prerelease: ${{ contains(env.TAG, 'rc') }} + files: | + dist/* diff --git a/geocluster/version.py b/geocluster/version.py new file mode 100644 index 0000000..7c1aef3 --- /dev/null +++ b/geocluster/version.py @@ -0,0 +1,11 @@ +_MAJOR = "0" +_MINOR = "1" +# On main and in a nightly release the patch should be one ahead of the last +# released build. +_PATCH = "0" +# This is mainly for nightly builds which have the suffix ".dev$DATE". See +# https://semver.org/#is-v123-a-semantic-version for the semantics. +_SUFFIX = "" + +VERSION_SHORT = "{0}.{1}".format(_MAJOR, _MINOR) +VERSION = "{0}.{1}.{2}{3}".format(_MAJOR, _MINOR, _PATCH, _SUFFIX) diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100644 index 0000000..a817f62 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +TAG=$(python -c 'from geocluster.version import VERSION; print("v" + VERSION)') + +read -p "Creating new release for $TAG. Do you want to continue? [Y/n] " prompt + +if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then + git add -A + git commit -m "Bump version to $TAG for release" || true && git push + echo "Creating new git tag $TAG" + git tag "$TAG" -m "$TAG" + git push --tags +else + echo "Cancelled" + exit 1 +fi