Skip to content

Commit

Permalink
feat: Adds CD pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
christopheralex committed Jan 29, 2022
1 parent 08c203c commit 7021a8c
Showing 1 changed file with 72 additions and 57 deletions.
129 changes: 72 additions & 57 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,81 @@
name: release

on:
push:
branches:
- main
pull_request:
branches:
- main
# Only run this job if the "build" job passes
workflow_run:
workflows: [build]
types: [completed]

jobs:
release:
# Only run this job if the "build" job passes
needs: build

on-success:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

# Set up operating system
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9]


# Set up operating system
runs-on: ubuntu-latest

steps:
# Set up Python 3.9
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
# Set up Python 3.9
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

# Check-out repository to access contents
- uses: actions/checkout@v2
with:
fetch-depth: 0

# Disables main branch protection for PSR
- name: Disable admin branch protection
uses: benjefferies/branch-protection-bot@master
if: always()
with:
access-token: ${{ secrets.ACCESS_TOKEN }}
branch: main
enforce_admins: false

# Check-out repository to access contents
- uses: actions/checkout@v2
with:
fetch-depth: 0
# Use PSR to make release
- name: Python Semantic Release
run: |
pip install python-semantic-release
git config user.name github-actions
git config user.email github-actions@github.com
semantic-release publish
# # Use PSR to make release
# - name: Python Semantic Release
# run: |
# pip install python-semantic-release
# git config user.name github-actions
# git config user.email github-actions@github.com
# semantic-release publish

# # Publish to TestPyPI
# - uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
# skip_existing: true

# # Test install from TestPyPI
# - name: Test install from TestPyPI
# run: |
# pip install \
# --index-url https://test.pypi.org/simple/ \
# --extra-index-url https://pypi.org/simple \
# airpyllution

# # Publish to PyPI
# - uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
# skip_existing: true
# Re enables main branch protection
- name: Enable admin branch protection
uses: benjefferies/branch-protection-bot@master
if: always() # Force to always run this step to ensure "include administrators" is always turned back on
with:
access-token: ${{ secrets.ACCESS_TOKEN }}
branch: main
enforce_admins: true

# Publish to TestPyPI
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

# Test install from TestPyPI
- name: Test install from TestPyPI
run: |
pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
airpyllution
# Publish to PyPI
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true

on_failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'

0 comments on commit 7021a8c

Please sign in to comment.