externalized config manager as a dependency #9
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: Publish Python Package to Artifact Registry | |
on: | |
push: | |
branches: [main] | |
env: | |
PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
REPOSITORY_NAME: encryption-manager-lib | |
ARTIFACT_REGISTRY_LOCATION: europe-west3 | |
PYTHON_VERSION: '3.10' | |
jobs: | |
build_and_publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout current repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install packaging tools | |
run: | | |
python -m pip install --upgrade pip setuptools wheel twine | |
- name: Build package | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Authenticate with Google Cloud and get access token | |
env: | |
GOOGLE_APPLICATION_CREDENTIALS_JSON: ${{ secrets.ARTIFACT_REGISTRY_KEY_DEV }} | |
run: | | |
gcloud auth activate-service-account --key-file=- <<< "$GOOGLE_APPLICATION_CREDENTIALS_JSON" | |
ACCESS_TOKEN=$(gcloud auth print-access-token) | |
echo "ACCESS_TOKEN=${ACCESS_TOKEN}" >> $GITHUB_ENV | |
- name: Publish package to Artifact Registry | |
run: | | |
python -m twine upload --verbose \ | |
--repository-url https://$ARTIFACT_REGISTRY_LOCATION-python.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/ \ | |
--username oauth2accesstoken \ | |
--password ${{ env.ACCESS_TOKEN }} \ | |
dist/* |