Skip to content

Commit

Permalink
Update GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Oct 8, 2024
1 parent 613b89d commit 825006a
Showing 1 changed file with 20 additions and 34 deletions.
54 changes: 20 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install rye
uses: eifinger/setup-rye@d4c3ac7b15d8bf2e0b45e2d257c6b5cdbebc3643 # v4.2.1
uses: eifinger/setup-rye@cba39b644640fb95c375ce5bfe2fdf33c0b815fc # v4.2.6
with:
version: '0.36.0'
version: '0.41.0'
enable-cache: true
cache-prefix: ${{ github.workflow }}
- name: Decide image tags
id: info
shell: python
run: |
import os
import itertools
registries = ['docker.io', 'ghcr.io']
repos = ['${{ github.repository }}'.lower()]
if '${{ github.ref_type }}' == 'branch':
tags = ['latest']
elif '${{ github.ref_type }}' == 'tag':
version = '${{ github.ref_name }}'[1:]
tags = ['latest', version]
else:
tags = []
def join_tag(t):
registry, repo, tag = t
return f'{registry}/{repo}:{tag}'

product = itertools.product(registries, repos, tags)
tags_csv = ','.join(map(join_tag, product))
push = 'true' if len(tags) >= 2 else 'false'

with open(os.environ['GITHUB_OUTPUT'], 'a') as out:
out.write(f'tags={tags_csv}\n')
out.write(f'push={push}\n')
- name: Set version
run: |
if [ '${{ github.ref_type }}' = 'tag' ]; then
Expand All @@ -59,15 +31,28 @@ jobs:
rye version > src/serie/version.txt
- name: Build Python wheel
run: rye build --wheel --clean
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
docker.io/${{ github.repository }}
ghcr.io/${{ github.repository }}
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: github.event_name == 'push'
id: dockerhub_login
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
id: ghcr_login
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
Expand All @@ -79,11 +64,12 @@ jobs:
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.info.outputs.tags }}
push: ${{ steps.info.outputs.push }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ steps.dockerhub_login.outcome == 'success' && steps.ghcr_login.outcome == 'success' }}
- name: Update DockerHub description
uses: peter-evans/dockerhub-description@v4
if: ${{ steps.info.outputs.push }}
if: ${{ steps.dockerhub_login.outcome == 'success' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
Expand Down

0 comments on commit 825006a

Please sign in to comment.