release: include Docker image tags and digests in GitHub Release notes #145
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: | | |
cat <<IMAGE_INFO | tee release-image-info-${{ matrix.id }}.md | |
* Tags: ${TAGS} | |
* Digest: \`${{ steps.docker_build.outputs.digest }}\` | |
IMAGE_INFO | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: release-image-info-${{ matrix.id }} | |
path: release-image-info-${{ matrix.id }}.md | |
- name: Test if groonga command is executable | |
run: | | |
docker container run --rm --entrypoint "groonga" "${TAG}" --version | |
release: | |
name: Release | |
needs: build | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
path: release-image-info | |
pattern: release-image-info-* | |
merge-multiple: true | |
- name: Prepare release note | |
run: | | |
echo "Groonga ${GITHUB_REF_NAME}" | tee release-title.txt | |
echo "* Commit: https://github.com/${GITHUB_REPOSITORY}/tree/${GITHUB_REF_NAME}" | | |
tee release-note.md | |
for image_info in release-image-info/*; do | |
cat $image_info | tee -a release-note.md | |
done | |
- name: Create GitHub Release | |
if: github.ref_type == 'tag' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create "${GITHUB_REF_NAME}" \ | |
--discussion-category Announcements \ | |
--notes-file release-note.md \ | |
--title "$(cat release-title.txt)" |