From 9aaa39b36c7617b14a362ad26059e45ddf3f246d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Birm=C3=A9?= Date: Thu, 29 Aug 2024 23:07:28 +0200 Subject: [PATCH] chore: build and push image on release (#5) --- .github/workflows/release.yml | 58 +++++++++++++++++++++++++++++++++++ RELEASE.md | 23 ++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 RELEASE.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ea884a9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Build and push Docker image when a release is published + +on: + release: + types: [published] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + name: Build and push Docker image + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Extract GUI version + id: gui + env: + TAGS: ${{ steps.meta.outputs.tags }} + run: echo "::set-output name=version::${TAGS##*:}" + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + build-args: | + GUI_VERSION=${{ steps.gui.outputs.version }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..ef69de6 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,23 @@ +To build and publish a release of the official Docker image, in this example patch version `v1.0.1`: + +1. Create a tag with name `v1.0.1` + +``` +% git tag v1.0.1 +``` + +2. Push the tag to GitHub remote + +``` +% git push --tags +``` + +3. Open browser and navigate to the repository on GitHub. Go to the Releases section by clicking on the Releases header on the right side of the page. + +4. Click on Create a new release and choose the tag `v1.0.1` that you created. + +5. Describe the release by adding release notes in the markdown input field. + +6. Click on Publish release. + +This will trigger a GitHub action that will build Docker image and tag it with `v1.0.1` and push to container registry.