From 83ecf0f7fce61a995f2f2b49a9aebbd674c57b98 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 10:57:06 -0400 Subject: [PATCH 01/17] add workflow to deploy docker on push --- .github/workflows/deploy-docker.yml | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/deploy-docker.yml diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml new file mode 100644 index 0000000000..27e5507460 --- /dev/null +++ b/.github/workflows/deploy-docker.yml @@ -0,0 +1,41 @@ +name: Artifacts + +on: + workflow_dispatch: + inputs: + tag: + default: '' + push: + tags: + - '*' + branches: + - master + +jobs: + deploy-ghcr: + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + # need to fetch unshallow so that setuptools_scm can infer the version + fetch-depth: 0 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: name/app + + - name: Login to ghcr.io + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 62d8ba5eef057a91bc1e08edd9ace7f1751145bb Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 10:58:28 -0400 Subject: [PATCH 02/17] fix name --- .github/workflows/deploy-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index 27e5507460..2f1bfe02e0 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -1,4 +1,4 @@ -name: Artifacts +name: Deploy docker image to ghcr.io on: workflow_dispatch: From 9d234b61f18b60b3923df590512740fc7b0ea58a Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:01:34 -0400 Subject: [PATCH 03/17] fix file --- .github/workflows/deploy-docker.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index 2f1bfe02e0..90b588c0fd 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -1,4 +1,4 @@ -name: Deploy docker image to ghcr.io +name: Deploy docker image on: workflow_dispatch: @@ -13,6 +13,12 @@ on: jobs: deploy-ghcr: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: - name: Checkout uses: actions/checkout@v3 From b5248e298080c484723446a63174412d44fa4ddc Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:06:29 -0400 Subject: [PATCH 04/17] fix image tags --- .github/workflows/deploy-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index 90b588c0fd..b6c3544184 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -30,7 +30,7 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: name/app + images: charles-cooper/vyper - name: Login to ghcr.io uses: docker/login-action@v2 From fa97f72004b7254c5006036d4324dc07cb7ed2c1 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:11:25 -0400 Subject: [PATCH 05/17] add sha tag --- .github/workflows/{deploy-docker.yml => ghcr.yml} | 2 ++ 1 file changed, 2 insertions(+) rename .github/workflows/{deploy-docker.yml => ghcr.yml} (93%) diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/ghcr.yml similarity index 93% rename from .github/workflows/deploy-docker.yml rename to .github/workflows/ghcr.yml index b6c3544184..e4ee7c2347 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/ghcr.yml @@ -31,6 +31,8 @@ jobs: uses: docker/metadata-action@v4 with: images: charles-cooper/vyper + tags: | + type=sha,prefix=sha-,format=short - name: Login to ghcr.io uses: docker/login-action@v2 From 019d2be528209f253075b0a9d19a4800449a4b33 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:13:29 -0400 Subject: [PATCH 06/17] fix registry --- .github/workflows/ghcr.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index e4ee7c2347..cee347992d 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -11,6 +11,10 @@ on: branches: - master +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + jobs: deploy-ghcr: @@ -30,14 +34,14 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: charles-cooper/vyper + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=sha,prefix=sha-,format=short - name: Login to ghcr.io uses: docker/login-action@v2 with: - registry: ghcr.io + registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} From c8afec253d309c9f819da25c461c528fed927dbe Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:15:13 -0400 Subject: [PATCH 07/17] change prefix --- .github/workflows/ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index cee347992d..8eb2ff64ff 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -36,7 +36,7 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=sha,prefix=sha-,format=short + type=sha,prefix=commit-,format=short - name: Login to ghcr.io uses: docker/login-action@v2 From 4b616e2b0be76d60bc0aa78a95c447bb902a6ce6 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:25:16 -0400 Subject: [PATCH 08/17] use vyper version to tag --- .github/workflows/ghcr.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 8eb2ff64ff..5db5394f4c 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -30,13 +30,24 @@ jobs: # need to fetch unshallow so that setuptools_scm can infer the version fetch-depth: 0 + - uses: actions/setup-python@v4 + name: Install python + with: + python-version: "3.11" + cache: "pip" + + - name: Generate vyper/version.py + run: | + pip install . + echo "VYPER_VERSION=$(PYTHONPATH=. python vyper/cli/vyper_compile.py --version)" >> "$GITHUB_ENV" + - name: Docker meta id: meta uses: docker/metadata-action@v4 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=sha,prefix=commit-,format=short + type=custom,value=${{ env.VYPER_VERSION }} - name: Login to ghcr.io uses: docker/login-action@v2 From ef0123351a9276c89c48e4cb3a9a90c1933a1735 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:26:16 -0400 Subject: [PATCH 09/17] fix tag name --- .github/workflows/ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 5db5394f4c..3f495a0618 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -47,7 +47,7 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=custom,value=${{ env.VYPER_VERSION }} + type=raw,value=${{ env.VYPER_VERSION }} - name: Login to ghcr.io uses: docker/login-action@v2 From 4183676903a8ed53416474d44b7c079ca685904a Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:28:52 -0400 Subject: [PATCH 10/17] add edge tag --- .github/workflows/ghcr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 3f495a0618..4a0c7f0742 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -47,6 +47,7 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | + type=edge type=raw,value=${{ env.VYPER_VERSION }} - name: Login to ghcr.io From 6286ddfd79b4c9eafb1e19ff41e4ac1c0eb7082d Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:30:28 -0400 Subject: [PATCH 11/17] add ref tag --- .github/workflows/ghcr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 4a0c7f0742..c72b2edeaa 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -47,6 +47,7 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | + type=ref type=edge type=raw,value=${{ env.VYPER_VERSION }} From 7f3759969c116b7342b453bf7ffff8c097bc536a Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:34:04 -0400 Subject: [PATCH 12/17] push: true --- .github/workflows/ghcr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index c72b2edeaa..3da08bdbf3 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -62,5 +62,6 @@ jobs: uses: docker/build-push-action@v4 with: context: . + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From f96052f01f4663d81b9627d7a5686bc397c5029a Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:35:01 -0400 Subject: [PATCH 13/17] publish branch --- .github/workflows/ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 3da08bdbf3..37430fc4a4 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -47,7 +47,7 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=ref + type=ref,event=branch type=edge type=raw,value=${{ env.VYPER_VERSION }} From d423bf35a52129ab9ba8d3856912598b93f330cb Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:35:39 -0400 Subject: [PATCH 14/17] add latest tag --- .github/workflows/ghcr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 37430fc4a4..e9daa5fd38 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -49,6 +49,7 @@ jobs: tags: | type=ref,event=branch type=edge + type=raw,value=latest,enable={{is_default_branch}} type=raw,value=${{ env.VYPER_VERSION }} - name: Login to ghcr.io From 8c8e4686fc353e43c73719f27ae1ddd04ae1065d Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:37:08 -0400 Subject: [PATCH 15/17] remove branch and edge tags --- .github/workflows/ghcr.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index e9daa5fd38..3ec546267f 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -47,8 +47,6 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=ref,event=branch - type=edge type=raw,value=latest,enable={{is_default_branch}} type=raw,value=${{ env.VYPER_VERSION }} From 5d699c31cf96f3d1e8776bb100068507f8ba358b Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 11:45:11 -0400 Subject: [PATCH 16/17] fix latest tag, add version tag --- .github/workflows/ghcr.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 3ec546267f..9680285793 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -1,15 +1,13 @@ -name: Deploy docker image +name: Deploy docker image on pushes to master and release on: - workflow_dispatch: - inputs: - tag: - default: '' push: tags: - '*' branches: - master + release: + types: [released] env: REGISTRY: ghcr.io @@ -46,8 +44,11 @@ jobs: uses: docker/metadata-action@v4 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + latest=true tags: | - type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=branch + type=ref,event=tag type=raw,value=${{ env.VYPER_VERSION }} - name: Login to ghcr.io From 348c09eef7728bf8702ff1352460430ea46fcf4e Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 19 May 2023 15:48:43 -0400 Subject: [PATCH 17/17] commit message publish and tag docker images continuously to ghcr.io. adds custom tagging so we can retain every commit. it's technically possible to do this on docker hub, but in order to have custom tags, you need to set up a regular user and log in/push via that user. the authentication is much cleaner in github actions for ghcr. (note docker hub pulls for releases are still staying the same, this is just an alternative form of retention going forward). --- .github/workflows/ghcr.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 9680285793..d227d6caf0 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -1,4 +1,10 @@ -name: Deploy docker image on pushes to master and release +name: Deploy docker image to ghcr + +# Deploy docker image to ghcr on pushes to master and all releases/tags. +# Note releases to docker hub are managed separately in another process +# (github sends webhooks to docker hub which triggers the build there). +# This workflow is an alternative form of retention for docker images +# which also allows us to tag and retain every single commit to master. on: push: