Skip to content

Commit f1e8a71

Browse files
committed
update ci pipeline
1 parent 83bbd1e commit f1e8a71

2 files changed

Lines changed: 45 additions & 87 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 45 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,54 @@
1-
# This workflow will create a github release and upload a Python Package to pypi
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3-
name: Release
4-
# Release a new version to different targets in suitable ways
1+
name: Build and Deploy to GitHub Container Registry
52

63
on:
7-
workflow_call: # called from ci.yml
8-
inputs:
9-
to_github:
10-
description: "Create a Github Release (repository snapshot)"
11-
type: boolean
12-
default: true
13-
14-
to_test_pypi:
15-
description: "Publish to Test PyPI."
16-
type: boolean
17-
default: false
18-
19-
to_pypi:
20-
description: "Publish to PyPI."
21-
type: boolean
22-
default: false
4+
release:
5+
types: [ published ]
6+
push:
7+
tags:
8+
- '*'
9+
workflow_dispatch:
2310

11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
2414

2515
jobs:
26-
27-
github:
28-
if: inputs.to_github
29-
name: Create a Github Release (repository snapshot)
16+
build-and-push:
3017
runs-on: ubuntu-latest
3118
permissions:
32-
contents: write # needed for creating a GH Release
33-
steps:
34-
- uses: actions/checkout@v3
35-
- uses: softprops/action-gh-release@v1
19+
contents: read
20+
packages: write
3621

37-
pypi:
38-
if: inputs.to_pypi || inputs.to_test_pypi
39-
name: Publish to PyPI (and/or compatible repositories)
40-
runs-on: ubuntu-latest
41-
permissions:
42-
id-token: write # needed for "trusted publishing" protocol
4322
steps:
44-
- uses: actions/checkout@v3
45-
46-
- name: Install poetry
47-
run: pipx install poetry
48-
49-
- uses: actions/setup-python@v4
50-
with:
51-
python-version: "3.10"
52-
cache: "poetry"
53-
54-
- name: Build the distribution package
55-
run: poetry build
56-
57-
- name: Publish package to TestPyPI
58-
if: inputs.to_test_pypi
59-
uses: pypa/gh-action-pypi-publish@release/v1
60-
with:
61-
repository-url: https://test.pypi.org/legacy/
62-
63-
- name: Publish package to PyPI
64-
if: inputs.to_pypi
65-
uses: pypa/gh-action-pypi-publish@release/v1
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Log in to the Container registry
30+
if: github.event_name != 'pull_request'
31+
uses: docker/login-action@v3
32+
with:
33+
registry: ${{ env.REGISTRY }}
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Extract metadata (tags, labels)
38+
id: meta
39+
uses: docker/metadata-action@v5
40+
with:
41+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
42+
tags: |
43+
type=ref,event=tag
44+
type=semver,pattern={{version}}
45+
type=semver,pattern={{major}}.{{minor}}
46+
type=raw,value=latest,enable={{is_default_branch}}
47+
48+
- name: Build and push Docker image
49+
uses: docker/build-push-action@v5
50+
with:
51+
context: .
52+
push: true
53+
tags: ${{ steps.meta.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)