Skip to content

Commit

Permalink
CI: Automatically generate 'latest tag' from 'tag' name instead of ha…
Browse files Browse the repository at this point in the history
…rdcoding 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').
  • Loading branch information
carlosperate committed Dec 28, 2023
1 parent 3b8e056 commit 0bc340f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,28 @@ 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:
registry: ghcr.io
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 }}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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:

Expand Down

0 comments on commit 0bc340f

Please sign in to comment.