Skip to content

Commit

Permalink
Make release workflow based on GH releases (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonagestam authored Jun 15, 2021
1 parent fddbe2b commit 891e96a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 63 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,53 +67,3 @@ jobs:
minimum_coverage: 80
show_missing: true
show_branch: true

release:
name: Create release
runs-on: ubuntu-latest
needs: [lint, test]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/rr/v')
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: pip cache
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
restore-keys: ${{ runner.os }}-pip
- name: Install build dependencies
run: |
python3 -m pip install --upgrade wheel setuptools .
- name: Validate version
id: version
run: |
tagged_version=${GITHUB_REF#refs/tags/rr/v}
code_version=$(python3 -c 'import phantom; print(phantom.__version__)')
if [[ "$tagged_version" != "$code_version" ]]; then
echo "Aborting due to version mismatch 💥"
echo "Tagged version: $tagged_version"
echo "Code version: $code_version"
exit 1
fi
echo "::set-output name=version::$tagged_version"
- name: Build
run: make build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Tag release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.version }}
release_name: ${{ steps.version.outputs.version }}
draft: false
prerelease: false
body: ""
27 changes: 27 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release

on:
release:
types: [published]

jobs:
build-and-publish:
name: Build and publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
restore-keys: ${{ runner.os }}-pip
- name: Install dependencies
run: python3 -m pip install --upgrade build
- name: Build
run: python3 -m build --sdist --wheel .
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ repos:
- iso3166
- phonenumbers
- pydantic
- repo: https://github.com/mgedmin/check-manifest
rev: "0.46"
hooks:
- id: check-manifest

exclude: |
(?x)(
Expand Down
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
exclude Makefile
recursive-exclude docs *
recursive-exclude examples *
recursive-exclude .github *
recursive-exclude tests *
recursive-include phantom py.typed
exclude *.yaml
exclude *.yml
include README.md
include LICENSE
14 changes: 1 addition & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ coverage-report:
@coverage report
@coverage xml

# TODO: Move to pre-commit
.PHONY: format-readme
format-readme:
docker run \
Expand All @@ -36,16 +37,3 @@ format-readme:
.PHONY: clean
clean:
rm -rf *.egg-info **{/**,}/__pycache__ build dist .coverage

.PHONY: build
build: clean
python3 -m pip install --upgrade wheel setuptools
python3 setup.py sdist bdist_wheel

.PHONY: create-release
create-release:
(\
tag="rr/v$$(python3 -c 'import phantom; print(phantom.__version__)')";\
git tag "$$tag";\
git push origin "$$tag";\
)

0 comments on commit 891e96a

Please sign in to comment.