add labels, quote some values

apply some standard labels from <https://github.com/opencontainers/image-spec/blob/main/annotations.md>

quotes some secrets in case they might contain shell special characters
This commit is contained in:
Ben Burke 2021-11-20 16:55:16 +00:00 committed by Mike Farah
parent 183007d120
commit 3f4bbf748d
1 changed files with 24 additions and 11 deletions

View File

@ -21,7 +21,7 @@ jobs:
- name: Get the version - name: Get the version
id: get_version id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF##*/} run: echo ::set-output name=VERSION::${GITHUB_REF##*/}
- name: Generate man page - name: Generate man page
uses: docker://pandoc/core:2.14.2 uses: docker://pandoc/core:2.14.2
id: gen-man-page id: gen-man-page
@ -35,7 +35,7 @@ jobs:
--variable=author:"Mike Farah" --variable=author:"Mike Farah"
--output=yq.1 --output=yq.1
${{ steps.gen-man-page-md.outputs.man-page-md }} ${{ steps.gen-man-page-md.outputs.man-page-md }}
- name: Cross compile - name: Cross compile
run: | run: |
sudo apt-get install rhash -y sudo apt-get install rhash -y
@ -67,12 +67,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
with: with:
platforms: all platforms: all
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
@ -81,16 +81,29 @@ jobs:
- name: Available platforms - name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }} && docker version run: echo ${{ steps.buildx.outputs.platforms }} && docker version
- name: Build and push image - name: Build and push image
run: | run: |
IMAGE_V_VERSION="$(git describe --tags --abbrev=0)" IMAGE_V_VERSION="$(git describe --tags --abbrev=0)"
IMAGE_VERSION=${IMAGE_V_VERSION:1} IMAGE_VERSION=${IMAGE_V_VERSION:1}
SHORT_SHA1=$(git rev-parse --short HEAD)
PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64" PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64"
echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}" echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}"
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u '${{ secrets.DOCKER_USERNAME }}' --password-stdin
docker buildx build --platform "${PLATFORMS}" -t "${IMAGE_NAME}:${IMAGE_VERSION}" -t "${IMAGE_NAME}:latest" -t "${IMAGE_NAME}:4" \ docker buildx build \
--push . --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}" \
--push \
-t "${IMAGE_NAME}:${IMAGE_VERSION}" \
-t "${IMAGE_NAME}:4" \
-t "${IMAGE_NAME}:latest" \
.