From 217744bc9ae9984599c5e9eb1eda8a26ab4f75df Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Tue, 12 Apr 2022 09:27:35 +1000 Subject: [PATCH] Pulled out docker build --- .github/workflows/docker-release.yml | 60 +++++++++++++++++++++++++ .github/workflows/release-published.yml | 29 ------------ .github/workflows/release.yml | 49 -------------------- 3 files changed, 60 insertions(+), 78 deletions(-) create mode 100644 .github/workflows/docker-release.yml delete mode 100644 .github/workflows/release-published.yml diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 00000000..0b501ef2 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,60 @@ +name: Release Docker + +on: + release: + types: [released] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + publishDocker: + environment: dockerhub + env: + IMAGE_NAME: mikefarah/yq + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: all + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + version: latest + + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} && docker version + + - name: Build and push image + run: | + echo "GithubRef: ${GITHUB_REF}" + IMAGE_VERSION=${GITHUB_REF:1} + echo "IMAGE_VERSION: ${IMAGE_VERSION}" + + PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64" + + echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}" + echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u '${{ secrets.DOCKER_USERNAME }}' --password-stdin + docker buildx build \ + --label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \ + --label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" \ + --label "org.opencontainers.image.description=yq is a portable command-line YAML processor" \ + --label "org.opencontainers.image.documentation=https://mikefarah.gitbook.io/yq/" \ + --label "org.opencontainers.image.licenses=MIT" \ + --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \ + --label "org.opencontainers.image.source=https://github.com/mikefarah/yq" \ + --label "org.opencontainers.image.title=yq" \ + --label "org.opencontainers.image.url=https://mikefarah.gitbook.io/yq/" \ + --label "org.opencontainers.image.version=${IMAGE_VERSION}" \ + --platform "${PLATFORMS}" \ + --pull \ + --push \ + -t "${IMAGE_NAME}:${IMAGE_VERSION}" \ + -t "${IMAGE_NAME}:4" \ + -t "${IMAGE_NAME}:latest" \ + . diff --git a/.github/workflows/release-published.yml b/.github/workflows/release-published.yml deleted file mode 100644 index d20a0e78..00000000 --- a/.github/workflows/release-published.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Release Published - -on: - release: - types: [created] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - publishToAlpinePackage: - runs-on: ubuntu-latest - - steps: - - name: Setup Go environment - uses: actions/setup-go@v3.0.0 - with: - go-version: 1.18 - check-latest: true - - name: Check out source code - uses: actions/checkout@v3 - - name: Run the processing script - env: - ALPINE_GITLAB_ACCESS_TOKEN: ${{secrets.ALPINE_GITLAB_ACCESS_TOKEN}} - ALPINE_GITLAB_FORK_REPO: ${{secrets.ALPINE_GITLAB_FORK_REPO}} - GIT_USERNAME: ${{secrets.GIT_USERNAME}} - GIT_EMAIL: ${{secrets.GIT_EMAIL}} - working-directory: ./pipeline/alpine-publisher - run: go run main.go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ac53f03d..ab78628b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,52 +59,3 @@ jobs: with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: build/* - - publishDocker: - environment: dockerhub - env: - IMAGE_NAME: mikefarah/yq - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - with: - platforms: all - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - with: - version: latest - - - name: Available platforms - run: echo ${{ steps.buildx.outputs.platforms }} && docker version - - - name: Build and push image - run: | - IMAGE_V_VERSION="$(git describe --tags --abbrev=0)" - IMAGE_VERSION=${IMAGE_V_VERSION:1} - PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64" - - echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}" - echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u '${{ secrets.DOCKER_USERNAME }}' --password-stdin - docker buildx build \ - --label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \ - --label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" \ - --label "org.opencontainers.image.description=yq is a portable command-line YAML processor" \ - --label "org.opencontainers.image.documentation=https://mikefarah.gitbook.io/yq/" \ - --label "org.opencontainers.image.licenses=MIT" \ - --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \ - --label "org.opencontainers.image.source=https://github.com/mikefarah/yq" \ - --label "org.opencontainers.image.title=yq" \ - --label "org.opencontainers.image.url=https://mikefarah.gitbook.io/yq/" \ - --label "org.opencontainers.image.version=${IMAGE_VERSION}" \ - --platform "${PLATFORMS}" \ - --pull \ - --push \ - -t "${IMAGE_NAME}:${IMAGE_VERSION}" \ - -t "${IMAGE_NAME}:4" \ - -t "${IMAGE_NAME}:latest" \ - .