chore: cleanup for dist #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Containerize Sylva | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- src/** | |
- pyproject.toml | |
- pdm.lock | |
- .github/workflows/containerize.yaml | |
- Dockerfile | |
- tests/** | |
- pytest.ini | |
- tox.ini | |
release: | |
types: | |
- published | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
packages: write | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Authenticate with Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Authenticate with the GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
submodules: true | |
- name: Determine release type | |
run: | | |
if [[ ${{ github.event_name }} == 'release' ]]; then | |
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then | |
echo "RELEASE_TYPE=prerelease" >> $GITHUB_ENV | |
else | |
echo "RELEASE_TYPE=release" >> $GITHUB_ENV | |
echo "TAG_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
fi | |
else | |
echo "RELEASE_TYPE=preview" >> $GITHUB_ENV | |
fi | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Sylva CLI to registries (stable) | |
if: ${{ env.RELEASE_TYPE == 'release' }} | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
target: cli-prod | |
context: . | |
tags: | | |
sylva/sylva:latest | |
sylva/sylva:${{ env.TAG_VERSION }} | |
ghcr.io/${{ github.repository_owner }}/sylva:latest | |
ghcr.io/${{ github.repository_owner }}/sylva:${{ env.TAG_VERSION }} | |
- name: Build and push Sylva CLI to registries (preview) | |
if: ${{ env.RELEASE_TYPE == 'prerelease' || env.RELEASE_TYPE == 'preview' }} | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
target: cli-prod | |
context: . | |
tags: | | |
sylva/sylva:preview | |
ghcr.io/${{ github.repository_owner }}/sylva:preview |