|
| 1 | +name: Release Docker |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [released] |
| 6 | + |
| 7 | + # Allows you to run this workflow manually from the Actions tab |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + publishDocker: |
| 12 | + environment: dockerhub |
| 13 | + env: |
| 14 | + IMAGE_NAME: mikefarah/yq |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v3 |
| 18 | + |
| 19 | + - name: Set up QEMU |
| 20 | + uses: docker/setup-qemu-action@v2 |
| 21 | + with: |
| 22 | + platforms: all |
| 23 | + |
| 24 | + - name: Set up Docker Buildx |
| 25 | + id: buildx |
| 26 | + uses: docker/setup-buildx-action@v2 |
| 27 | + with: |
| 28 | + version: latest |
| 29 | + |
| 30 | + - name: Available platforms |
| 31 | + run: echo ${{ steps.buildx.outputs.platforms }} && docker version |
| 32 | + |
| 33 | + - name: Build and push image |
| 34 | + run: | |
| 35 | + echo "GithubRef: ${GITHUB_REF}" |
| 36 | + VERSION=${GITHUB_REF##*/} |
| 37 | + echo "VERSION: ${VERSION}" |
| 38 | + IMAGE_VERSION=${VERSION:1} |
| 39 | + echo "IMAGE_VERSION: ${IMAGE_VERSION}" |
| 40 | +
|
| 41 | + PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64" |
| 42 | +
|
| 43 | + echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}" |
| 44 | + echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u '${{ secrets.DOCKER_USERNAME }}' --password-stdin |
| 45 | + cd github-action |
| 46 | + docker buildx build \ |
| 47 | + --label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \ |
| 48 | + --label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" \ |
| 49 | + --label "org.opencontainers.image.description=yq is a portable command-line YAML processor" \ |
| 50 | + --label "org.opencontainers.image.documentation=https://mikefarah.gitbook.io/yq/" \ |
| 51 | + --label "org.opencontainers.image.licenses=MIT" \ |
| 52 | + --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \ |
| 53 | + --label "org.opencontainers.image.source=https://github.com/mikefarah/yq" \ |
| 54 | + --label "org.opencontainers.image.title=yq" \ |
| 55 | + --label "org.opencontainers.image.url=https://mikefarah.gitbook.io/yq/" \ |
| 56 | + --label "org.opencontainers.image.version=${IMAGE_VERSION}" \ |
| 57 | + --platform "${PLATFORMS}" \ |
| 58 | + --pull \ |
| 59 | + --push \ |
| 60 | + -t "${IMAGE_NAME}:${IMAGE_VERSION}-githubaction" \ |
| 61 | + -t "${IMAGE_NAME}:4-githubaction" \ |
| 62 | + -t "${IMAGE_NAME}:latest-githubaction" \ |
| 63 | + . |
0 commit comments