-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup actions for test, build and release (#7)
Adds test, prepare-release and publish-pypi workflows.
- Loading branch information
Showing
4 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Announcements | ||
* First announcement | ||
|
||
# Changes |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
|
||
name: Prepare Release | ||
|
||
jobs: | ||
autorelease: | ||
name: Prepare Release | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2.3.4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Python | ||
uses: actions/setup-python@v2.2.2 | ||
with: | ||
python-version: "3.8" | ||
- name: python --version | ||
run: | | ||
python --version | ||
python3 --version | ||
- name: Setup protoc | ||
uses: arduino/setup-protoc@v1 | ||
with: | ||
version: "3.17.3" | ||
- name: protoc --version | ||
run: protoc --version | ||
- name: Permacache Poetry | ||
id: cache-poetry | ||
uses: actions/cache@v2.1.6 | ||
with: | ||
path: ~/.poetry | ||
key: poetry | ||
- name: Install latest version of Poetry | ||
if: steps.cache-poetry.outputs.cache-hit != 'true' | ||
run: | | ||
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - | ||
- name: Add Poetry to $PATH | ||
run: | | ||
echo "$HOME/.poetry/bin" >> $GITHUB_PATH | ||
- name: Add version to environment vars | ||
run: | | ||
PROJECT_VERSION=$(poetry version --short) | ||
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV | ||
- name: Check if tag version matches project version | ||
run: | | ||
TAG=$(git describe HEAD --tags --abbrev=0) | ||
echo $TAG | ||
echo $PROJECT_VERSION | ||
if [[ "$TAG" != "v$PROJECT_VERSION" ]]; then exit 1; fi | ||
- name: poetry --version | ||
run: poetry --version | ||
- name: Check pyproject.toml validity | ||
run: poetry check --no-interaction | ||
- name: Cache dependencies | ||
id: cache-deps | ||
uses: actions/cache@v2.1.6 | ||
with: | ||
path: ${{github.workspace}}/.venv | ||
key: poetry-${{ hashFiles('**/poetry.lock') }} | ||
restore-keys: poetry- | ||
- name: Install deps | ||
if: steps.cache-deps.cache-hit != 'true' | ||
run: | | ||
poetry config virtualenvs.in-project true | ||
poetry install --no-interaction | ||
- name: Run tests | ||
run: poetry run python -m unittest test.test_protogen | ||
- name: Build | ||
run: poetry build | ||
- name: Release Notes | ||
run: git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s%n * %an <%ae>' --no-merges >> ".github/RELEASE-TEMPLATE.md" | ||
- name: Create Release Draft | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
body_path: ".github/RELEASE-TEMPLATE.md" | ||
draft: true | ||
files: | | ||
dist/protogen-${{env.PROJECT_VERSION}}-py3-none-any.whl | ||
dist/protogen-${{env.PROJECT_VERSION}}.tar.gz | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
name: PyPI Publish | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2.3.4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v2.2.2 | ||
with: | ||
python-version: "3.8" | ||
- name: Permacache Poetry | ||
id: cache-poetry | ||
uses: actions/cache@v2.1.6 | ||
with: | ||
path: ~/.poetry | ||
key: poetry | ||
- name: Install latest version of Poetry | ||
if: steps.cache-poetry.outputs.cache-hit != 'true' | ||
run: | | ||
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - | ||
- name: Add Poetry to $PATH | ||
run: | | ||
echo "$HOME/.poetry/bin" >> $GITHUB_PATH | ||
- name: Get Poetry version | ||
run: poetry --version | ||
- name: Check pyproject.toml validity | ||
run: poetry check --no-interaction | ||
- name: Cache dependencies | ||
id: cache-deps | ||
uses: actions/cache@v2.1.6 | ||
with: | ||
path: ${{github.workspace}}/.venv | ||
key: poetry-${{ hashFiles('**/poetry.lock') }} | ||
restore-keys: poetry- | ||
- name: Install deps | ||
if: steps.cache-deps.cache-hit != 'true' | ||
run: | | ||
poetry config virtualenvs.in-project true | ||
poetry install --no-interaction | ||
- name: Publish to PyPI | ||
env: | ||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | ||
run: | | ||
poetry config pypi-token.pypi $PYPI_TOKEN | ||
poetry publish --build |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
on: | ||
push: | ||
branches: [main, actions] | ||
pull_request: | ||
branches: [main, actions] | ||
|
||
name: Test | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
test: | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2.3.4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v2.2.2 | ||
with: | ||
python-version: 3.8 | ||
- name: python --version | ||
run: | | ||
python --version | ||
python3 --version | ||
- name: Setup protoc | ||
uses: arduino/setup-protoc@v1 | ||
with: | ||
version: "3.17.3" | ||
- name: protoc --version | ||
run: protoc --version | ||
# Perma-cache Poetry since we only need it for checking pyproject version | ||
- name: Cache Poetry | ||
id: cache-poetry | ||
uses: actions/cache@v2.1.6 | ||
with: | ||
path: ~/.poetry | ||
key: poetry | ||
# Only runs when key from caching step changes | ||
- name: Install latest version of Poetry | ||
if: steps.cache-poetry.outputs.cache-hit != 'true' | ||
run: | | ||
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - | ||
# Poetry still needs to be re-prepended to the PATH on each run, since | ||
# PATH does not persist between runs. | ||
- name: Add Poetry to $PATH | ||
run: | | ||
echo "$HOME/.poetry/bin" >> $GITHUB_PATH | ||
- name: Get Poetry version | ||
run: poetry --version | ||
- name: Check pyproject.toml validity | ||
run: poetry check --no-interaction | ||
- name: Cache dependencies | ||
id: cache-deps | ||
uses: actions/cache@v2.1.6 | ||
with: | ||
path: ${{github.workspace}}/.venv | ||
key: deps-${{ hashFiles('**/poetry.lock') }} | ||
- name: Install deps | ||
if: steps.cache-deps.cache-hit != 'true' | ||
run: | | ||
poetry config virtualenvs.in-project true | ||
poetry install --no-interaction | ||
- name: Run tests | ||
run: poetry run python -m unittest test.test_protogen | ||
- name: Build artifacts | ||
run: poetry build |