From 0bc340ff91393650d03dcf962ca54b702bf873c4 Mon Sep 17 00:00:00 2001 From: Carlos Pereira Atencio Date: Thu, 28 Dec 2023 18:51:23 +0000 Subject: [PATCH] CI: Automatically generate 'latest tag' from 'tag' name instead of hardcoding it. Otherwise every time we change between buster-legacy and bullseye we have to touch the release.yml file to change the tag name for 'latest' (e.g. 'buster-latest', 'bullseye-latest'). --- .github/workflows/release.yml | 26 +++++++++++++++----------- README.md | 10 +++++----- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f1b4ba..4a2e149 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,10 +10,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - shell: bash + - name: Set release tag to env variables $TAG + # id: get_version + # run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + # shell: bash + run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set 'latest tag' (e.g. buster-legacy-2022-04-19 -> buster-latest) to env variable $TAG_LATEST + run: python -c "t='$TAG'.split('-')[0]; print(f'TAG_LATEST={t}-latest')" >> $GITHUB_ENV + - run: echo "Release tag is '$TAG' and latest tag is '${{ env.TAG_LATEST }}'" - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -21,13 +25,13 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.CR_PAT }} - name: Build base image (expanded disk) with latest tag - run: docker build -t ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:buster-legacy-latest --build-arg FILE_SUFFIX=autologin-ssh-expanded . - - name: Tag the base image with the versioned tag - run: docker tag ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:buster-legacy-latest ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:${{ steps.get_version.outputs.VERSION }} + run: docker build -t ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:${{ env.TAG_LATEST }} --build-arg FILE_SUFFIX=autologin-ssh-expanded . + - name: Also tag the base image with the versioned tag + run: docker tag ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:${{ env.TAG_LATEST }} ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:${{ env.TAG }} - name: Build Mu image - run: docker build -t ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:${{ steps.get_version.outputs.VERSION }}-mu --build-arg FILE_SUFFIX=mu . + run: docker build -t ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:${{ env.TAG }}-mu --build-arg FILE_SUFFIX=mu . - name: Push images to ghcr.io run: | - docker push ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:${{ steps.get_version.outputs.VERSION }}-mu - docker push ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:${{ steps.get_version.outputs.VERSION }} - docker push ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:buster-legacy-latest + docker push ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:${{ env.TAG }}-mu + docker push ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:${{ env.TAG }} + docker push ghcr.io/${{ github.repository_owner }}/qemu-rpi-os-lite:${{ env.TAG_LATEST }} diff --git a/README.md b/README.md index a12940d..fb4cc6e 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ the hard work goes to them. The main difference in this version is that the has been updated to enable auto-login, SSH, and expand their filesystem size. These changes make these images useful for things like running automated -tests on CI, like within GitHub Actions. +tests on CI, e.g. GitHub Actions. ## How to use these images @@ -61,7 +61,7 @@ docker run -it -p 5022:5022 ghcr.io/carlosperate/qemu-rpi-os-lite:bullseye-lates ## Available Images There are two main releases right now `buster-legacy-latest` and -'bullseye-latest': +`bullseye-latest`: ``` ghcr.io/carlosperate/qemu-rpi-os-lite:bullseye-latest @@ -71,15 +71,15 @@ ghcr.io/carlosperate/qemu-rpi-os-lite:bullseye-latest ghcr.io/carlosperate/qemu-rpi-os-lite:buster-legacy-latest ``` -Each Pi OS release has it's own tag, including the OS release date in this +Each Pi OS release has its own tag, including the OS release date in this format: ``` -ghcr.io/carlosperate/qemu-rpi-os-lite:buster-yyyy-mm-dd-mu +ghcr.io/carlosperate/qemu-rpi-os-lite:buster-yyyy-mm-dd ``` There also is an additional tag on each release with the postfix `mu` in the -tag name, which is an specialised image created specifically to contain the +tag name, which is an specialised image created specifically to include the [Mu Editor](https://github.com/mu-editor/mu) dependencies pre-installed, which is used for CI tests on that project: