Add workflow for registring package #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v3 | |
- 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: 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/* | |
env: | |
REPOSITORY: ${{ secrets.REPOSITORY }} | |
LOCATION: ${{ secrets.LOCATION }} | |
PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
GCP_SA_KEY_BASE64: ${{ secrets.GCP_SA_KEY_BASE64 }} |