Skip to content

Commit

Permalink
Set registry image name based on mainnet/testnet/betanet tags (#5)
Browse files Browse the repository at this point in the history
* Set registry image name based on mainnet/testnet/betanet tags
  • Loading branch information
hsoerensen authored Aug 14, 2024
1 parent 436bfb2 commit b1a3ae8
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 13 deletions.
32 changes: 28 additions & 4 deletions .github/workflows/build-legacy-relay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- 'v[0-9]*'
tags:
- 'v*'
- 'mainnet'
- 'betanet'
- 'testnet'
pull_request:
workflow_dispatch:

Expand All @@ -18,6 +21,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.platforms.outputs.matrix }}
registry_image: ${{ steps.registry_image.outputs.registry_image }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -31,6 +35,19 @@ jobs:
run: |
echo ${{ steps.platforms.outputs.matrix }}
- name: Set Git Tag as Environment Variable
id: git_tag
run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Set Registry Image Based on Tag
if: startsWith(env.GIT_TAG, 'mainnet') || startsWith(env.GIT_TAG, 'betanet') || startsWith(env.GIT_TAG, 'testnet')
run: |
echo "REGISTRY_IMAGE=${{ env.REGISTRY_IMAGE }}-${{ env.GIT_TAG }}" >> $GITHUB_ENV
- name: Set registry_image output
id: registry_image
run: echo "registry_image=${{ env.REGISTRY_IMAGE }}" >> $GITHUB_OUTPUT

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand All @@ -40,6 +57,7 @@ jobs:
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=ref,event=pr
type=raw,value=latest,enable=${{ startsWith(env.GIT_TAG, 'mainnet') || startsWith(env.GIT_TAG, 'betanet') || startsWith(env.GIT_TAG, 'testnet') }}
- name: Rename meta bake definition file
run: |
Expand Down Expand Up @@ -106,7 +124,7 @@ jobs:
set: |
*.tags=
*.platform=${{ matrix.platform }}
*.output=type=image,"name=${{ env.REGISTRY_IMAGE }}",push-by-digest=true,name-canonical=true,push=true
*.output=type=image,"name=${{ needs.prepare.outputs.registry_image }}",push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
Expand All @@ -126,7 +144,13 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
- prepare
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Download meta bake definition
uses: actions/download-artifact@v4
with:
Expand All @@ -153,9 +177,9 @@ jobs:
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.REGISTRY_IMAGE }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ needs.prepare.outputs.registry_image }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \
$(printf '${{ needs.prepare.outputs.registry_image }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json)
docker buildx imagetools inspect ${{ needs.prepare.outputs.registry_image }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json)
32 changes: 28 additions & 4 deletions .github/workflows/build-participation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- 'v[0-9]*'
tags:
- 'v*'
- 'mainnet'
- 'betanet'
- 'testnet'
pull_request:
workflow_dispatch:

Expand All @@ -18,6 +21,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.platforms.outputs.matrix }}
registry_image: ${{ steps.registry_image.outputs.registry_image }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -31,6 +35,19 @@ jobs:
run: |
echo ${{ steps.platforms.outputs.matrix }}
- name: Set Git Tag as Environment Variable
id: git_tag
run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Set Registry Image Based on Tag
if: startsWith(env.GIT_TAG, 'mainnet') || startsWith(env.GIT_TAG, 'betanet') || startsWith(env.GIT_TAG, 'testnet')
run: |
echo "REGISTRY_IMAGE=${{ env.REGISTRY_IMAGE }}-${{ env.GIT_TAG }}" >> $GITHUB_ENV
- name: Set registry_image output
id: registry_image
run: echo "registry_image=${{ env.REGISTRY_IMAGE }}" >> $GITHUB_OUTPUT

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand All @@ -40,6 +57,7 @@ jobs:
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=ref,event=pr
type=raw,value=latest,enable=${{ startsWith(env.GIT_TAG, 'mainnet') || startsWith(env.GIT_TAG, 'betanet') || startsWith(env.GIT_TAG, 'testnet') }}
- name: Rename meta bake definition file
run: |
Expand Down Expand Up @@ -106,7 +124,7 @@ jobs:
set: |
*.tags=
*.platform=${{ matrix.platform }}
*.output=type=image,"name=${{ env.REGISTRY_IMAGE }}",push-by-digest=true,name-canonical=true,push=true
*.output=type=image,"name=${{ needs.prepare.outputs.registry_image }}",push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
Expand All @@ -126,7 +144,13 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
- prepare
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Download meta bake definition
uses: actions/download-artifact@v4
with:
Expand All @@ -153,9 +177,9 @@ jobs:
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.REGISTRY_IMAGE }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ needs.prepare.outputs.registry_image }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \
$(printf '${{ needs.prepare.outputs.registry_image }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json)
docker buildx imagetools inspect ${{ needs.prepare.outputs.registry_image }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json)
34 changes: 29 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ on:
- 'main'
- 'v[0-9]*'
tags:
- 'v*'
- 'v*'
- 'mainnet'
- 'betanet'
- 'testnet'
pull_request:
workflow_dispatch:

Expand All @@ -18,6 +21,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.platforms.outputs.matrix }}
registry_image: ${{ steps.registry_image.outputs.registry_image }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -31,6 +35,19 @@ jobs:
run: |
echo ${{ steps.platforms.outputs.matrix }}
- name: Set Git Tag as Environment Variable
id: git_tag
run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Set Registry Image Based on Tag
if: startsWith(env.GIT_TAG, 'mainnet') || startsWith(env.GIT_TAG, 'betanet') || startsWith(env.GIT_TAG, 'testnet')
run: |
echo "REGISTRY_IMAGE=${{ env.REGISTRY_IMAGE }}-${{ env.GIT_TAG }}" >> $GITHUB_ENV
- name: Set registry_image output
id: registry_image
run: echo "registry_image=${{ env.REGISTRY_IMAGE }}" >> $GITHUB_OUTPUT

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand All @@ -40,6 +57,7 @@ jobs:
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=ref,event=pr
type=raw,value=latest,enable=${{ startsWith(env.GIT_TAG, 'mainnet') || startsWith(env.GIT_TAG, 'betanet') || startsWith(env.GIT_TAG, 'testnet') }}
- name: Rename meta bake definition file
run: |
Expand Down Expand Up @@ -106,7 +124,7 @@ jobs:
set: |
*.tags=
*.platform=${{ matrix.platform }}
*.output=type=image,"name=${{ env.REGISTRY_IMAGE }}",push-by-digest=true,name-canonical=true,push=true
*.output=type=image,"name=${{ needs.prepare.outputs.registry_image }}",push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
Expand All @@ -126,7 +144,13 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
- prepare
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Download meta bake definition
uses: actions/download-artifact@v4
with:
Expand All @@ -153,9 +177,9 @@ jobs:
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.REGISTRY_IMAGE }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ needs.prepare.outputs.registry_image }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \
$(printf '${{ needs.prepare.outputs.registry_image }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json)
docker buildx imagetools inspect ${{ needs.prepare.outputs.registry_image }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json)

0 comments on commit b1a3ae8

Please sign in to comment.