release: include Docker image tags and digests in GitHub Release notes #138
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
- push | |
- pull_request | |
concurrency: | |
group: ${{ github.head_ref || github.sha }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: ${{ matrix.id }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
id: | |
- "alpine" | |
- "debian" | |
steps: | |
- name: Parse ID | |
run: | | |
set -x | |
distribution=${{ matrix.id }} | |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then | |
version="${GITHUB_REF_NAME}" | |
else | |
version=latest | |
fi | |
tag="groonga/groonga:${version}-${{ matrix.id }}" | |
tags="${tag}" | |
if [ ${{ matrix.id }} = "debian" -a "${version}" = "latest" ]; then | |
tags="${tags},groonga/groonga:latest" | |
fi | |
need_push="no" | |
if [ "${GITHUB_EVENT_NAME}" = "push" ] && [ "${GITHUB_REPOSITORY}" = "groonga/docker" ]; then | |
need_push="yes" | |
fi | |
echo "DISTRIBUTION=${distribution}" >> ${GITHUB_ENV} | |
echo "CONTEXT=./${distribution}" >> ${GITHUB_ENV} | |
echo "TAG=${tag}" >> ${GITHUB_ENV} | |
echo "TAGS=${tags}" >> ${GITHUB_ENV} | |
echo "NEED_PUSH=${need_push}" >> ${GITHUB_ENV} | |
- uses: actions/checkout@v4 | |
- uses: docker/login-action@v3 | |
if: env.NEED_PUSH == 'yes' | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- uses: docker/setup-buildx-action@v3 | |
id: buildx | |
- uses: docker/build-push-action@v6 | |
id: docker_build | |
with: | |
# cache-from: type=gha | |
# cache-to: type=gha,mode=max | |
context: ${{ env.CONTEXT }} | |
push: ${{ env.NEED_PUSH == 'yes' }} | |
load: ${{ env.NEED_PUSH != 'yes' }} | |
tags: ${{ env.TAGS }} | |
- name: Image info | |
run: | | |
dockerfile=${{ matrix.id }}/Dockerfile | |
groonga_version=$(grep -o 'GROONGA_VERSION=[0-9.]*' ${dockerfile} | \ | |
cut -d= -f2 | \ | |
head -n1) | |
echo "Groonga ${groonga_version}" | tee release-title.txt | |
cat <<RELEASE_NOTE | tee release-note.md | |
* Commit: https://github.com/${GITHUB_REPOSITORY}/tree/${GITHUB_REF_NAME} | |
* Tags: ${TAGS} | |
* Digest: \`${{ steps.docker_build.outputs.digest }}\` | |
RELEASE_NOTE | |
- name: Create GitHub Release | |
if: github.ref_type == 'tag' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then | |
echo "Release page for ${GITHUB_REF_NAME} already exists." | |
else | |
gh release create "${GITHUB_REF_NAME}" \ | |
--discussion-category Announcements \ | |
--notes-file release-note.md \ | |
--title "$(cat release-title.txt)" | |
fi | |
- name: Test if groonga command is executable | |
run: | | |
docker container run --rm --entrypoint "groonga" "${TAG}" --version |