Skip to content

Commit

Permalink
ci(github): add GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
elmernocon committed Dec 8, 2023
1 parent 0190d11 commit 0cbcc49
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish to DockerHub
on:
release:
types: [ published ]
workflow_dispatch: {}
jobs:
build-and-publish:
name: Build image and Publish to DockerHub
runs-on: ubuntu-latest
steps:
# This action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.
- name: Checkout
id: checkout
uses: actions/checkout@v3
- name: Setup QEMU
# GitHub Action to install QEMU static binaries.
id: setup-qemu
uses: docker/setup-qemu-action@v3
# This action will create and boot a builder that can be used in the following steps of your workflow if you're using Buildx or the build-push action.
- name: Setup Docker Buildx
id: setup-docker-buildx
uses: docker/setup-buildx-action@v3
# GitHub Action to login against a Docker registry.
- name: Login to Docker Hub
id: login-to-docker-hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# GitHub Action to build and push Docker images with Buildx with full support of the features provided by Moby BuildKit builder toolkit.
- name: Build and Push
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: elmernocon/semverkit:latest,elmernocon/semverkit:${{ github.event.release.tag_name }}
48 changes: 48 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish to PyPI
on:
release:
types: [ published ]
workflow_dispatch: {}
jobs:
build-and-publish:
name: Build package and Publish to PyPI
strategy:
fail-fast: true
max-parallel: 1
matrix:
os:
- ubuntu-latest
python-version:
- 3.9
runs-on: ${{ matrix.os }}
environment:
name: pypi
url: https://pypi.org/p/semverkit
permissions:
id-token: write
steps:
# This action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.
- name: Checkout
id: checkout
uses: actions/checkout@master
# This action provides the following functionality for GitHub Actions users:
# - Installing a version of Python or PyPy and (by default) adding it to the PATH
# - Optionally caching dependencies for pip, pipenv and poetry
# - Registering problem matchers for error output
- name: Setup Python
id: setup-python
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
- name: Install Build
id: install-build
run: |
python -m pip install --upgrade build
- name: Run Build
id: run-build
run: |
python -m build --sdist --wheel
# This action allows you to upload your Python distribution packages in the dist/ directory to PyPI.
- name: Publish to PyPI
id: pypi-publish
uses: pypa/gh-action-pypi-publish@release/v1
49 changes: 49 additions & 0 deletions .github/workflows/testpypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish to Test PyPI
on:
workflow_dispatch: {}
jobs:
build-and-publish:
name: Build package and Publish to Test PyPI
strategy:
fail-fast: true
max-parallel: 1
matrix:
os:
- ubuntu-latest
python-version:
- 3.9
runs-on: ${{ matrix.os }}
environment:
name: testpypi
url: https://test.pypi.org/p/semverkit
permissions:
id-token: write
steps:
# This action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.
- name: Checkout
id: checkout
uses: actions/checkout@master
# This action provides the following functionality for GitHub Actions users:
# - Installing a version of Python or PyPy and (by default) adding it to the PATH
# - Optionally caching dependencies for pip, pipenv and poetry
# - Registering problem matchers for error output
- name: Setup Python
id: setup-python
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
- name: Install Build
id: install-build
run: |
python -m pip install --upgrade build
- name: Run Build
id: run-build
run: |
python -m build --sdist --wheel
# This action allows you to upload your Python distribution packages in the dist/ directory to PyPI.
- name: Publish to Test PyPI
id: pypi-publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true

0 comments on commit 0cbcc49

Please sign in to comment.