aboutsummaryrefslogtreecommitdiffstats
path: root/.github
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2022-05-31 14:06:54 -0700
committerGravatar MarkKoz <[email protected]>2022-05-31 14:09:16 -0700
commit8d33cab2cb3baf179941e9692b682150d50bbbe5 (patch)
tree1498f265d4f294c0afac774676305235980ec20b /.github
parentFix package discovery for setuptools (diff)
Docker: install package in image and use version to tag it
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/build.yaml24
-rw-r--r--.github/workflows/deploy.yaml7
-rw-r--r--.github/workflows/main.yaml4
-rw-r--r--.github/workflows/test.yaml6
4 files changed, 20 insertions, 21 deletions
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 28e5b69..e5791c9 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -4,9 +4,9 @@ on:
artifact:
description: The name of the uploaded image aretfact.
value: ${{ jobs.build.outputs.artifact }}
- tag:
- description: The tag used for the built image.
- value: ${{ jobs.build.outputs.tag }}
+ version:
+ description: The package's version.
+ value: ${{ jobs.build.outputs.version }}
jobs:
build:
@@ -14,21 +14,21 @@ jobs:
runs-on: ubuntu-latest
outputs:
artifact: ${{ env.artifact }}
- tag: ${{ steps.sha_tag.outputs.tag }}
+ version: ${{ steps.version.outputs.version }}
env:
artifact: image_artifact_snekbox-venv
steps:
- # Create a short SHA with which to tag built images.
- - name: Create SHA Container Tag
- id: sha_tag
- run: |
- tag=$(cut -c 1-7 <<< $GITHUB_SHA)
- echo "::set-output name=tag::$tag"
-
- name: Checkout code
uses: actions/checkout@v2
+ - name: Get version
+ id: version
+ run: |
+ set -eu
+ version=$(python scripts/version.py)
+ echo "::set-output name=version::version"
+
# The current version (v2) of Docker's build-push action uses buildx,
# which comes with BuildKit. It has cache features which can speed up
# the builds. See https://github.com/docker/build-push-action
@@ -83,7 +83,7 @@ jobs:
ghcr.io/python-discord/snekbox-base:latest
ghcr.io/python-discord/snekbox-venv:latest
cache-to: ${{ steps.cache_config.outputs.cache_to }}
- tags: ghcr.io/python-discord/snekbox-venv:${{ steps.sha_tag.outputs.tag }}
+ tags: ghcr.io/python-discord/snekbox-venv:${{ steps.version.outputs.version }}
# Make the image available as an artifact so other jobs will be able to
# download it.
diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml
index 3b12921..977c317 100644
--- a/.github/workflows/deploy.yaml
+++ b/.github/workflows/deploy.yaml
@@ -4,7 +4,7 @@ on:
artifact:
required: true
type: string
- tag:
+ version:
required: true
type: string
secrets:
@@ -55,8 +55,7 @@ jobs:
cache-to: type=inline
tags: |
ghcr.io/python-discord/snekbox:latest
- ghcr.io/python-discord/snekbox:${{ inputs.tag }}
- build-args: git_sha=${{ github.sha }}
+ ghcr.io/python-discord/snekbox:${{ inputs.version }}
# Deploy to Kubernetes.
- name: Authenticate with Kubernetes
@@ -69,7 +68,7 @@ jobs:
uses: Azure/k8s-deploy@v1
with:
manifests: deployment.yaml
- images: 'ghcr.io/python-discord/snekbox:${{ inputs.tag }}'
+ images: 'ghcr.io/python-discord/snekbox:${{ inputs.version }}'
kubectl-version: 'latest'
# Push the base image to GHCR, with an inline cache manifest.
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index f28ab61..b581ba3 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -16,13 +16,13 @@ jobs:
needs: build
with:
artifact: ${{ needs.build.outputs.artifact }}
- tag: ${{ needs.build.outputs.tag }}
+ version: ${{ needs.build.outputs.version }}
deploy:
uses: ./.github/workflows/deploy.yaml
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
needs: [build, lint, test]
with:
artifact: ${{ needs.build.outputs.artifact }}
- tag: ${{ needs.build.outputs.tag }}
+ version: ${{ needs.build.outputs.version }}
secrets:
KUBECONFIG: ${{ secrets.KUBECONFIG }}
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index f7f3635..a9fcade 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -4,7 +4,7 @@ on:
artifact:
required: true
type: string
- tag:
+ version:
required: true
type: string
@@ -38,7 +38,7 @@ jobs:
- name: Run tests
id: run_tests
run: |
- export IMAGE_SUFFIX='-venv:${{ inputs.tag }}'
+ export IMAGE_SUFFIX='-venv:${{ inputs.version }}'
docker-compose run \
--rm -T -e COVERAGE_DATAFILE=.coverage.${{ matrix.os }} \
snekbox \
@@ -57,7 +57,7 @@ jobs:
- name: Docker cleanup
if: matrix.os == 'self-hosted' && always()
run: |
- export IMAGE_SUFFIX='-venv:${{ inputs.tag }}'
+ export IMAGE_SUFFIX='-venv:${{ inputs.version }}'
docker-compose down --rmi all --remove-orphans -v -t 0
report: