Skip to content

Reduce workflow

Reduce workflow #12

name: Register package to GCP Artifact Registry
on:
workflow_dispatch:
push:
branches:
- main
jobs:
register:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install dependencies
run: |
pip install --upgrade pip
pip install build twine keyring keyrings.google-artifactregistry-auth
- name: Build Python package
run: |
python -m build
- name: Authenticate with GCP
uses: google-github-actions/auth@v0.5.0
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Activate service account
run: |
gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS
- name: Create .pypirc file
run: |
echo "[distutils]
index-servers =
${{ secrets.REPOSITORY }}
[${{ secrets.REPOSITORY }}]
repository: https://${{ secrets.LOCATION }}-python.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REPOSITORY }}/
username: _json_key_base64
password: ${{ secrets.GCP_SA_KEY_BASE64 }}" > ~/.pypirc
- name: Register package
run: |
twine upload -r ${{ secrets.REPOSITORY }} dist/* --verbose