test #2
This file contains hidden or 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: Release | |
| on: | |
| push: | |
| branches: | |
| - main # for nightly releases | |
| tags: | |
| - "*" | |
| jobs: | |
| docker_build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-tags: true | |
| fetch-depth: 0 | |
| - name: Get image tag | |
| id: tag | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/heads/master ]]; then | |
| echo "tag=nightly" >> $GITHUB_OUTPUT | |
| else | |
| echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Get project version | |
| id: project_version | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/heads/master ]]; then | |
| TAG=$(git describe --tags --abbrev=0) | |
| BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's/\//-/g') | |
| COMMIT=$(git rev-parse --short=8 HEAD) | |
| VERSION="${TAG}-git.${BRANCH}.${COMMIT}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set version in pyproject.toml | |
| run: sed -i '/^\[project\]/,/^\[/s|version = "unknown-version"|version = "${{ steps.project_version.outputs.version }}"|' pyproject.toml | |
| - name: Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository }}:{{ steps.tag.outputs.tag }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |