Skip to content

Commit 87c9c67

Browse files
authored
Update to release workflow template file (#6)
* use explicit source for iam pypi repo * incorporate changes from netid_arrest release script into templated script
1 parent 11f699b commit 87c9c67

File tree

3 files changed

+74
-66
lines changed

3 files changed

+74
-66
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Release on push to `main`
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- pyproject.toml
8+
workflow_dispatch:
9+
10+
jobs:
11+
publish-if-new-version:
12+
if: github.repository != 'UWIT-IAM/example-flask-app'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 2
18+
19+
# Only publish if the version has changed; otherwise, we would be
20+
# re-publishing existing stuff without updating the version, and that
21+
# could cause problems.
22+
- name: Check if the change should be published
23+
if: github.event_name != 'workflow_dispatch'
24+
run: |
25+
set -x
26+
publishable=false
27+
diff=$(git diff HEAD:pyproject.toml HEAD~1:pyproject.toml) || exit 0
28+
echo "$diff" | grep '+version ='
29+
if [[ "$?" -ne 0 ]]
30+
then
31+
echo 'Not publishable - skipping'
32+
exit 1
33+
fi
34+
35+
- uses: uwit-iam/action-setup-poetry-project@main
36+
id: auth
37+
with:
38+
credentials: "${{ secrets.MCI_GCLOUD_AUTH_JSON }}"
39+
enable_private_docker: true
40+
enable_private_pypi: true
41+
42+
- name: Run validation checks and tests
43+
run: |
44+
poetry run pytest
45+
poetry run flake8
46+
poetry run black --check .
47+
48+
- name: Calculate versioning variables
49+
id: get-version
50+
run: |
51+
echo "version=$(poetry version -s)" >> $GITHUB_OUTPUT
52+
echo "timestamp=$(date --utc +%Y.%m.%d.%H.%M.%S)" >> $GITHUB_OUTPUT
53+
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
57+
- name: Build and push Docker image
58+
uses: docker/build-push-action@v5
59+
with:
60+
context: .
61+
file: ./Dockerfile
62+
push: true
63+
target: app
64+
tags: |
65+
us-docker.pkg.dev/uwit-mci-iam/containers/${template:app_name}:${{ steps.get-version.outputs.version }}
66+
us-docker.pkg.dev/uwit-mci-iam/containers/${template:app_name}:deploy-dev.${{ steps.get-version.outputs.timestamp }}.v${{ steps.get-version.outputs.version }}
67+
secret-files: |
68+
"gcloud_auth_credentials=${{ steps.auth.outputs.credentials_file_path }}"
69+

.github/workflows/release-on-push-to-main.yaml

-66
This file was deleted.

pyproject.template.toml

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ uw-it-build-fingerprinter = "^0.2.6"
1515
black = "^22.6.0"
1616
flake8 = "^5.0.2"
1717

18+
[[tool.poetry.source]]
19+
name = "iam-pypi"
20+
url = "https://us-python.pkg.dev/uwit-mci-iam/iam-pypi/simple/"
21+
priority = "explicit"
22+
1823
[build-system]
1924
requires = ["poetry-core>=1.0.0"]
2025
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)