diff --git a/.gitea/workflows/auto-release.yaml b/.gitea/workflows/auto-release.yaml new file mode 100644 index 0000000..d1339e7 --- /dev/null +++ b/.gitea/workflows/auto-release.yaml @@ -0,0 +1,40 @@ +name: Auto release + +on: + push: + branches: [ "master" ] + paths: + - Makefile + +jobs: + tag_on_change: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5.0.0 + with: + fetch-depth: 0 + - name: Check if DC_VERSION line changed + id: check_change + run: | + echo "changed=false" >> $GITHUB_OUTPUT + + for file in Makefile; do + if git diff HEAD~1 HEAD -- "${file}" | grep --quiet '^[+-]DC_VERSION'; then + echo "DC_VERSION line changed." + echo "changed=true" >> $GITHUB_OUTPUT + break + fi + done + + - name: Stop if no change detected + if: steps.check_change.outputs.changed == 'false' + run: echo "No DC_VERSION change. Exiting..." + + - name: Trigger "Push tagged images" workflow + if: steps.check_change.outputs.changed == 'true' + uses: peter-evans/repository-dispatch@v4.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + event-type: push-tagged-images \ No newline at end of file diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 19ce8d6..bc9e134 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -4,12 +4,26 @@ on: push: tags: - "**" + repository_dispatch: + types: [ push-tagged-images ] jobs: push-arm64: runs-on: ubuntu-latest-arm64 steps: + - id: version_extraction + name: Extract git tag + run: | + VERSION="${{ github.event.client_payload.tag || github.ref_name }}" + VERSION="${VERSION#refs/*/}" + echo "Version: ${VERSION}" + echo "version=${VERSION}" >> $GITHUB_OUTPUT + - uses: actions/checkout@v5.0.0 + with: + fetch-tags: true + ref: "${{ steps.version_extraction.outputs.version }}" + - uses: docker/setup-qemu-action@v3.6.0 - uses: docker/setup-buildx-action@v3.11.1 @@ -21,20 +35,30 @@ jobs: - name: Build and push image run: | - TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm') - docker buildx build \ --platform linux/arm64 \ --file Dockerfile \ --provenance false \ - --tag git.cryptic.systems/volker.raschek/docker-compose:${TAG}-arm64 \ + --tag git.cryptic.systems/volker.raschek/docker-compose:${{ steps.version_extraction.outputs.version }}-arm64 \ --push \ . push-amd64: runs-on: ubuntu-latest-amd64 steps: + - id: version_extraction + name: Extract git tag + run: | + VERSION="${{ github.event.client_payload.tag || github.ref_name }}" + VERSION="${VERSION#refs/*/}" + echo "Version: ${VERSION}" + echo "version=${VERSION}" >> $GITHUB_OUTPUT + - uses: actions/checkout@v5.0.0 + with: + fetch-tags: true + ref: "${{ steps.version_extraction.outputs.version }}" + - uses: docker/setup-qemu-action@v3.6.0 - uses: docker/setup-buildx-action@v3.11.1 @@ -46,13 +70,11 @@ jobs: - name: Build and push image run: | - TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm') - docker buildx build \ --platform linux/amd64 \ --file Dockerfile \ --provenance false \ - --tag git.cryptic.systems/volker.raschek/docker-compose:${TAG}-amd64 \ + --tag git.cryptic.systems/volker.raschek/docker-compose:${{ steps.version_extraction.outputs.version }}-amd64 \ --push \ . @@ -62,6 +84,14 @@ jobs: - push-arm64 - push-amd64 steps: + - id: version_extraction + name: Extract git tag + run: | + VERSION="${{ github.event.client_payload.tag || github.ref_name }}" + VERSION="${VERSION#refs/*/}" + echo "Version: ${VERSION}" + echo "version=${VERSION}" >> $GITHUB_OUTPUT + - uses: docker/login-action@v3.6.0 with: registry: git.cryptic.systems @@ -70,30 +100,36 @@ jobs: - name: Create and push manifest run: | - TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm') + docker manifest create git.cryptic.systems/volker.raschek/docker-compose:${{ steps.version_extraction.outputs.version }} \ + --amend git.cryptic.systems/volker.raschek/docker-compose:${{ steps.version_extraction.outputs.version }}-amd64 \ + --amend git.cryptic.systems/volker.raschek/docker-compose:${{ steps.version_extraction.outputs.version }}-arm64 - docker manifest create git.cryptic.systems/volker.raschek/docker-compose:${TAG} \ - --amend git.cryptic.systems/volker.raschek/docker-compose:${TAG}-amd64 \ - --amend git.cryptic.systems/volker.raschek/docker-compose:${TAG}-arm64 - - docker manifest push git.cryptic.systems/volker.raschek/docker-compose:${TAG} + docker manifest push git.cryptic.systems/volker.raschek/docker-compose:${{ steps.version_extraction.outputs.version }} sync-to-hub-docker-io: needs: - push-manifest runs-on: ubuntu-latest steps: - - name: Copy images to docker.io - run: | - TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm') + - id: version_extraction + name: Extract git tag + run: | + VERSION="${{ github.event.client_payload.tag || github.ref_name }}" + VERSION="${VERSION#refs/*/}" + echo "Version: ${VERSION}" + echo "version=${VERSION}" >> $GITHUB_OUTPUT - apt-get update --yes - apt-get install --yes skopeo - skopeo copy \ - --all \ - --dest-password ${{ secrets.DOCKER_IO_PASSWORD }} \ - --dest-username ${{ secrets.DOCKER_IO_USERNAME }} \ - --src-password ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }} \ - --src-username volker.raschek \ - docker://git.cryptic.systems/volker.raschek/docker-compose:${TAG} \ - docker://docker.io/volkerraschek/docker-compose:${TAG} \ No newline at end of file + - name: Copy images to docker.io + run: | + TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm') + + apt-get update --yes + apt-get install --yes skopeo + skopeo copy \ + --all \ + --dest-password ${{ secrets.DOCKER_IO_PASSWORD }} \ + --dest-username ${{ secrets.DOCKER_IO_USERNAME }} \ + --src-password ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }} \ + --src-username volker.raschek \ + docker://git.cryptic.systems/volker.raschek/docker-compose:${{ steps.version_extraction.outputs.version }} \ + docker://docker.io/volkerraschek/docker-compose:${{ steps.version_extraction.outputs.version }} \ No newline at end of file