add logo image #none #18
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: "Build, Tag, and Release" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - .gitignore | |
| - .github/renovate.json | |
| - .pre-commit-config.yaml | |
| - LICENSE | |
| - README.MD | |
| - docs/ | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-tag-release: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} | |
| permissions: | |
| contents: write | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get next version | |
| id: version | |
| uses: anothrNick/github-tag-action@e528bc2b9628971ce0e6f823f3052d1dcd9d512c # 1.73.0 | |
| env: | |
| WITH_V: true | |
| DEFAULT_BUMP: patch | |
| DRY_RUN: true | |
| - name: Check if version changed | |
| id: changed | |
| continue-on-error: true | |
| run: | | |
| if [[ "${{ steps.version.outputs.new_tag }}" == "${{ steps.version.outputs.old_tag }}" ]]; then | |
| echo "Version not changed" | |
| exit 1 | |
| else | |
| echo "Version changed" | |
| fi | |
| - name: Install uv | |
| if: ${{ steps.changed.outcome == 'success' }} | |
| uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6 | |
| - name: Bump version in files | |
| if: ${{ steps.changed.outcome == 'success' }} | |
| run: | | |
| version="${{ steps.version.outputs.new_tag }}" | |
| clean_version="${version#v}" | |
| sed -i "s/__version__ = .*/__version__ = \"${clean_version}\"/" src/restic_compose_backup/__init__.py | |
| sed -i "s/version = .*/version = \"${clean_version}\"/" src/pyproject.toml | |
| sed -i "s/release = .*/release = \"${clean_version}\"/" docs/conf.py | |
| uv lock --directory src --upgrade-package restic-compose-backup | |
| - name: Commit changes | |
| if: ${{ steps.changed.outcome == 'success' }} | |
| uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5 | |
| with: | |
| commit_message: automated version bump | |
| - name: Push version tag | |
| if: ${{ steps.changed.outcome == 'success' }} | |
| uses: anothrNick/github-tag-action@e528bc2b9628971ce0e6f823f3052d1dcd9d512c # 1.73.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| CUSTOM_TAG: ${{ steps.version.outputs.new_tag }} | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3 | |
| - name: Generate metadata for published image | |
| id: meta | |
| run: | | |
| TAG=${{ steps.version.outputs.new_tag }} | |
| echo "version=${TAG#v}" >> $GITHUB_OUTPUT | |
| echo "timestamp=$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')" >> $GITHUB_OUTPUT | |
| - name: Build and push Docker image | |
| id: push | |
| uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6 | |
| with: | |
| context: src/ | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} | |
| ${{ steps.changed.outcome == 'success' && format('{0}/{1}:latest', env.REGISTRY, env.IMAGE_NAME) || null }} | |
| ${{ steps.changed.outcome == 'success' && format('{0}/{1}:{2}', env.REGISTRY, env.IMAGE_NAME, steps.version.outputs.new_tag) || null }} | |
| labels: | | |
| org.opencontainers.image.title=${{ github.event.repository.name }} | |
| org.opencontainers.image.url=${{ github.repositoryUrl }} | |
| org.opencontainers.image.source=${{ github.repositoryUrl }} | |
| org.opencontainers.image.version=${{ steps.meta.outputs.version }} | |
| org.opencontainers.image.revision=${{ steps.commit.outputs.commit_hash }} | |
| org.opencontainers.image.created=${{ steps.meta.outputs.timestamp }} | |
| - name: Generate artifact attestation | |
| uses: actions/attest-build-provenance@db473fddc028af60658334401dc6fa3ffd8669fd # v2 | |
| with: | |
| subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
| subject-digest: ${{ steps.push.outputs.digest }} | |
| push-to-registry: true | |
| - name: Update release | |
| if: ${{ steps.changed.outcome == 'success' }} | |
| uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1 | |
| with: | |
| allowUpdates: true | |
| updateOnlyUnreleased: true | |
| generateReleaseNotes: true | |
| tag: ${{ steps.version.outputs.new_tag }} |