diff --git a/.github/workflows/dev-publish.yml b/.github/workflows/dev-publish.yml index 473625e..1266ca9 100644 --- a/.github/workflows/dev-publish.yml +++ b/.github/workflows/dev-publish.yml @@ -10,6 +10,9 @@ on: jobs: untagged-cleanup: name: Cleanup not tagged refs + environment: + name: "github-registry" + url: https://github.com/orgs/wdes/packages?repo_name=mail-autodiscover-autoconfig runs-on: ubuntu-latest permissions: packages: write @@ -25,6 +28,9 @@ jobs: build-binaries: name: Build multi arch binaries (${{ matrix.arch }}-${{ matrix.variant }}) for ${{ matrix.os }} + environment: + name: "github-registry" + url: https://github.com/orgs/wdes/packages?repo_name=mail-autodiscover-autoconfig runs-on: ubuntu-latest strategy: fail-fast: false @@ -113,6 +119,9 @@ jobs: build-image: runs-on: ubuntu-latest + environment: + name: "github-registry" + url: https://github.com/orgs/wdes/packages?repo_name=mail-autodiscover-autoconfig strategy: fail-fast: false max-parallel: 4 @@ -159,6 +168,9 @@ jobs: runs-on: ubuntu-latest needs: build-image name: Create the image manifest + environment: + name: "github-registry" + url: https://github.com/orgs/wdes/packages?repo_name=mail-autodiscover-autoconfig steps: - name: Login to the registry uses: docker/login-action@v3 @@ -185,6 +197,9 @@ jobs: runs-on: ubuntu-latest needs: create-final-image name: Cleanup build tags + environment: + name: "github-registry" + url: https://github.com/orgs/wdes/packages?repo_name=mail-autodiscover-autoconfig strategy: fail-fast: false max-parallel: 1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0ba730b..f6f4695 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,9 +4,9 @@ permissions: contents: read on: - push: - tags: - - "*" + release: + types: + - published jobs: build-image: @@ -107,34 +107,34 @@ jobs: #- { platform: "linux/ppc64le", internal-tag: "ppc64le" } - { platform: "linux/amd64", internal-tag: "amd64" } steps: - - name: Install Docker hub-tool - run: | - curl -sL https://github.com/docker/hub-tool/releases/download/v0.4.5/hub-tool-linux-amd64.tar.gz -o hub-tool-linux.tar.gz - tar --strip-components=1 -xzf ./hub-tool-linux.tar.gz - ./hub-tool --version - - name: Login hub-tool - run: | - # Fool the login command (https://github.com/docker/hub-tool/pull/198) - # ./hub-tool login - # Token commands thank to https://stackoverflow.com/a/59334315/5155484 - HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"$DOCKER_USERNAME\", \"password\": \"$DOCKER_PASSWORD\"}" https://hub.docker.com/v2/users/login/ | jq -r .token) - USERNAME="$(printf '%s:' "$DOCKER_USERNAME" | base64 -w0)" - USER_PASS="$(printf '%s:%s' "$DOCKER_USERNAME" "$DOCKER_PASSWORD" | base64 -w0)" - mkdir -p ~/.docker/ - printf '{"auths": {"hub-tool": {"auth": "%s"}, "hub-tool-refresh-token": {"auth": "%s"}, "hub-tool-token": { "auth": "%s", "identitytoken": "%s"}}}' \ - "$USER_PASS" "$USERNAME" \ - "$USERNAME" "$HUB_TOKEN" \ - > ~/.docker/config.json - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_HUB_USER }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} - - name: Remove PR container image via hub-tool - run: | - ./hub-tool tag rm --verbose --force docker.io/wdes/mail-autodiscover-autoconfig:${{ matrix.internal-tag }}-latest || true - ./hub-tool tag ls --verbose ocker.io/wdes/mail-autodiscover-autoconfig - - name: Logout hub-tool - if: always() - run: rm ~/.docker/config.json + - name: Install Docker hub-tool + run: | + curl -sL https://github.com/docker/hub-tool/releases/download/v0.4.5/hub-tool-linux-amd64.tar.gz -o hub-tool-linux.tar.gz + tar --strip-components=1 -xzf ./hub-tool-linux.tar.gz + ./hub-tool --version + - name: Login hub-tool + run: | + # Fool the login command (https://github.com/docker/hub-tool/pull/198) + # ./hub-tool login + # Token commands thank to https://stackoverflow.com/a/59334315/5155484 + HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"$DOCKER_USERNAME\", \"password\": \"$DOCKER_PASSWORD\"}" https://hub.docker.com/v2/users/login/ | jq -r .token) + USERNAME="$(printf '%s:' "$DOCKER_USERNAME" | base64 -w0)" + USER_PASS="$(printf '%s:%s' "$DOCKER_USERNAME" "$DOCKER_PASSWORD" | base64 -w0)" + mkdir -p ~/.docker/ + printf '{"auths": {"hub-tool": {"auth": "%s"}, "hub-tool-refresh-token": {"auth": "%s"}, "hub-tool-token": { "auth": "%s", "identitytoken": "%s"}}}' \ + "$USER_PASS" "$USERNAME" \ + "$USERNAME" "$HUB_TOKEN" \ + > ~/.docker/config.json + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_HUB_USER }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + - name: Remove PR container image via hub-tool + run: | + ./hub-tool tag rm --verbose --force docker.io/wdes/mail-autodiscover-autoconfig:${{ matrix.internal-tag }}-latest || true + ./hub-tool tag ls --verbose ocker.io/wdes/mail-autodiscover-autoconfig + - name: Logout hub-tool + if: always() + run: rm ~/.docker/config.json publish-binaries: name: Publish multi arch binaries on the release draft (${{ matrix.arch }}-${{ matrix.variant }}) for ${{ matrix.os }} @@ -225,10 +225,9 @@ jobs: if-no-files-found: error retention-days: 1 - - name: Publish to draft - uses: fnkr/github-action-ghr@ghr-options - env: - GHR_COMPRESS: xz - GHR_PATH: builds/ - GHR_DRAFT: yes - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file_glob: builds/* + tag: ${{ github.ref }}