Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from crazy-max/split-workflow
Browse files Browse the repository at this point in the history
ci: split build and release workflows
  • Loading branch information
crazy-max authored Apr 3, 2022
2 parents 7c53a53 + cc9bb3e commit b50237c
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 39 deletions.
41 changes: 6 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand All @@ -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
Expand All @@ -65,25 +49,12 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push image
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_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' }}
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b50237c

Please sign in to comment.