Skip to content

Commit

Permalink
(ci) release : merge two workflows to same on release
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Mar 25, 2024
1 parent b12cd94 commit 75267b1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 81 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/build-and-push-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Create and publish a Docker image & pip package

on:
release:
types: [published]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: API/
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

build-and-push-pypi:
runs-on: ubuntu-latest
needs: build-and-push-image

steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build package
run: python setup.py sdist bdist_wheel
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
49 changes: 0 additions & 49 deletions .github/workflows/docker-image-build-publish.yml

This file was deleted.

32 changes: 0 additions & 32 deletions .github/workflows/pypi-upload.yml

This file was deleted.

0 comments on commit 75267b1

Please sign in to comment.