-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (88 loc) · 3.32 KB
/
Copy pathmain.yml
File metadata and controls
95 lines (88 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Build and publish the package to internal PDBe PyPi registry, Dockerhub and GitLab Container Registry
permissions:
contents: read
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- "*"
env:
BASE_PYTHON_VERSION: &base_python_version "3.10"
jobs:
build:
name: Lint and Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [*base_python_version, "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
uv sync --locked --all-extras --dev
- name: Run pre-commit checks
uses: pre-commit/[email protected]
if: matrix.python-version == env.BASE_PYTHON_VERSION
- name: Run Tests
run: |
uv run make test
publish:
name: Publish
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/pisa-analysis
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "${{ env.BASE_PYTHON_VERSION }}"
- name: Create distribution
run: |
uv build
- name: Publish to internal PyPi
run: |
pip install twine
TWINE_PASSWORD=${{ secrets.TWINE_PASSWORD }} TWINE_USERNAME=${{ secrets.TWINE_USERNAME }} python -m twine upload --repository-url ${{ secrets.PIP_INDEX_URL }} dist/*
- name: Publish to public PyPi
uses: pypa/gh-action-pypi-publish@release/v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract Docker tag from GitHub ref
run: echo "DOCKER_TAG=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64/v8
tags: |
${{ secrets.DOCKER_USERNAME }}/pisa-analysis:${{ env.DOCKER_TAG }}
${{ secrets.DOCKER_USERNAME }}/pisa-analysis:latest
- name: Login to GitLab Container Registry
run: echo ${{ secrets.REGISTRY_PASSWORD }} | docker login -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin ${{ vars.REGISTRY_URL }}
- name: Build and tag Docker image
run: docker build -t ${{ vars.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/packages/pisa-analysis:latest -t ${{ vars.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/packages/pisa-analysis:${{ env.DOCKER_TAG }} .
- name: Push Docker image to GitLab Container Registry
run: |
docker push ${{ vars.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/packages/pisa-analysis:latest
docker push ${{ vars.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/packages/pisa-analysis:${{ env.DOCKER_TAG }}