diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06a111c..13e4333 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,15 +1,6 @@ name: build on: - workflow_dispatch: - inputs: - version: - description: 'Buildx version (e.g. v0.8.1)' - required: true - dry-run: - description: 'Dry run' - required: true - type: boolean push: branches: - 'main' @@ -24,11 +15,6 @@ jobs: build: runs-on: ubuntu-latest steps: - - - name: Set Buildx version - if: github.event.inputs.version != '' - run: | - echo "BUILDX_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV - name: Dump context uses: crazy-max/ghaction-dump-context@v1 @@ -43,13 +29,11 @@ jobs: images: | ${{ env.REPO_SLUG }} tags: | - type=raw,value=${{ env.BUILDX_VERSION }},enable=${{ github.event.inputs.version != '' }} - type=raw,value=${{ env.BUILDX_VERSION }}-${{ env.GITHUB_RUN_NUMBER }},enable=${{ github.event.inputs.version != '' }} - type=ref,event=branch,enable=${{ github.event.inputs.version == '' }} - type=ref,event=pr,enable=${{ github.event.inputs.version == '' }} + type=ref,event=branch + type=ref,event=pr labels: | - github.buildx-packaging.run-id=${{ env.GITHUB_RUN_ID }} - github.buildx-packaging.run-number=${{ env.GITHUB_RUN_NUMBER }} + github.buildx-packaging.run_id=${{ github.run_id }} + github.buildx-packaging.run_number=${{ github.run_number }} bake-target: meta-helper - name: Set up QEMU @@ -65,7 +49,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push image + name: Build uses: docker/bake-action@v1 with: files: | @@ -73,17 +57,4 @@ jobs: ${{ steps.meta.outputs.bake-file }} targets: pkg-cross set: | - *.output=type=image,push=${{ github.event_name != 'pull_request' && github.event.inputs.dry-run != 'true' }} - - - name: Create Release - uses: softprops/action-gh-release@9729932bfb75c05ad1f6e3a729294e05abaa7001 - if: github.event.inputs.version != '' && github.event.inputs.dry-run != 'true' - with: - name: ${{ env.BUILDX_VERSION }}-${{ env.GITHUB_RUN_NUMBER }} - tag_name: ${{ env.BUILDX_VERSION }}-${{ env.GITHUB_RUN_NUMBER }} - target_commitish: ${{ github.sha }} - body: | - * Tags pushed: [`${{ env.REPO_SLUG }}:${{ env.BUILDX_VERSION }}`, `${{ env.REPO_SLUG }}:${{ env.BUILDX_VERSION }}-${{ env.GITHUB_RUN_NUMBER }}`](https://hub.docker.com/r/${{ env.REPO_SLUG }}) - * Buildx release: https://github.com/docker/buildx/releases/tag/${{ env.BUILDX_VERSION }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + *.output=type=image,push=${{ github.event_name != 'pull_request' }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fb9ef18 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,81 @@ +name: release + +on: + workflow_dispatch: + inputs: + version: + description: 'Buildx version (e.g. v0.8.1)' + required: true + dry-run: + description: 'Dry run' + required: true + type: boolean + +env: + #REPO_SLUG: "docker/buildx-pkg" # FIXME: uncomment when moved to docker org and don't forget to update secrets + REPO_SLUG: "crazymax/buildx-packaging" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Set Buildx version + run: | + echo "BUILDX_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV + - + name: Dump context + uses: crazy-max/ghaction-dump-context@v1 + - + name: Checkout + uses: actions/checkout@v3 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ${{ env.REPO_SLUG }} + tags: | + type=raw,value=${{ env.BUILDX_VERSION }} + type=raw,value=${{ env.BUILDX_VERSION }}-${{ github.run_number }} + labels: | + github.buildx-packaging.run_id=${{ github.run_id }} + github.buildx-packaging.run_number=${{ github.run_number }} + bake-target: meta-helper + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + if: github.event.inputs.dry-run != 'true' + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build + uses: docker/bake-action@v1 + with: + files: | + ./docker-bake.hcl + ${{ steps.meta.outputs.bake-file }} + targets: pkg-cross + set: | + *.output=type=image,push=${{ github.event.inputs.dry-run != 'true' }} + - + name: Create Release + uses: softprops/action-gh-release@9729932bfb75c05ad1f6e3a729294e05abaa7001 + if: github.event.inputs.dry-run != 'true' + with: + name: ${{ env.BUILDX_VERSION }}-${{ github.run_number }} + tag_name: ${{ env.BUILDX_VERSION }}-${{ github.run_number }} + target_commitish: ${{ github.sha }} + body: | + * Tags pushed: [`${{ env.REPO_SLUG }}:${{ env.BUILDX_VERSION }}`, `${{ env.REPO_SLUG }}:${{ env.BUILDX_VERSION }}-${{ github.run_number }}`](https://hub.docker.com/r/${{ env.REPO_SLUG }}) + * Buildx release: https://github.com/docker/buildx/releases/tag/${{ env.BUILDX_VERSION }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 99574d5..12d7d92 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # Buildx packaging +[![GitHub release](https://img.shields.io/github/release/crazy-max/buildx-packaging.svg?style=flat-square)](https://github.com/crazy-max/buildx-packaging/releases/latest) [![Build Status](https://img.shields.io/github/workflow/status/crazy-max/buildx-packaging/build?label=build&logo=github)](https://github.com/crazy-max/buildx-packaging/actions?query=workflow%3Abuild) +[![Release Status](https://img.shields.io/github/workflow/status/crazy-max/buildx-packaging/release?label=release&logo=github)](https://github.com/crazy-max/buildx-packaging/actions?query=workflow%3Arelease) [![Docker Pulls](https://img.shields.io/docker/pulls/crazymax/buildx-packaging.svg?logo=docker)](https://hub.docker.com/r/crazymax/buildx-packaging/) This repository creates packages (apk, deb, rpm, static) for [buildx](https://github.com/docker/buildx) -that will be pushed on [`docker/buildx-pkg` Docker Hub repository](https://hub.docker.com/r/docker/buildx-pkg). +that are pushed on [`docker/buildx-pkg` Docker Hub repository](https://hub.docker.com/r/docker/buildx-pkg). ## Usage @@ -21,8 +23,8 @@ $ PKG_TYPES=deb PKG_DEB_RELEASES=debian11 docker buildx bake pkg # create packages for windows/amd64 platform and output to ./bin folder $ docker buildx bake --set *.platform=windows/amd64 --set *.output=./bin pkg -# create packages for all supported platforms and push to crazymax/buildx-pkg:latest -$ docker buildx bake --set *.output=type=image,push=true --set *.tags=crazymax/buildx-pkg:latest pkg-cross +# create packages for all supported platforms and push to crazymax/buildx-packaging:v0.8.1 +$ docker buildx bake --set *.output=type=image,push=true --set *.tags=crazymax/buildx-packaging:v0.8.1 pkg-cross ``` ## Extract packages @@ -31,7 +33,7 @@ You can use a tool like [Undock](https://github.com/crazy-max/undock) to extract all packages with: ```shell -$ undock --wrap --rm-dist --all crazymax/buildx-pkg:latest ./bin +$ undock --wrap --rm-dist --all crazymax/buildx-packaging:v0.8.1 ./bin $ tree ./bin ./dist/ ├── darwin