Skip to content

Commit 58a8b90

Browse files
committed
chore: add prerelease support
1 parent 7a0dadb commit 58a8b90

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

.github/workflows/radio-container.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
runs-on: ubuntu-latest
1616
outputs:
1717
version: ${{ steps.package-version.outputs.version }}
18+
is_prerelease: ${{ steps.package-version.outputs.is_prerelease }}
19+
prerelease_tag: ${{ steps.package-version.outputs.prerelease_tag }}
1820
steps:
1921
- name: Checkout repository
2022
uses: actions/checkout@v4
@@ -29,6 +31,15 @@ jobs:
2931
VERSION=$(node -p "require('./packages/radio/package.json').version")
3032
echo "version=${VERSION}" >> $GITHUB_OUTPUT
3133
34+
if [[ "$VERSION" =~ - ]]; then
35+
echo "is_prerelease=true" >> $GITHUB_OUTPUT
36+
PRERELEASE_TAG=$(echo "$VERSION" | sed -E 's/.*-([a-z]+).*/\1/')
37+
echo "prerelease_tag=${PRERELEASE_TAG}" >> $GITHUB_OUTPUT
38+
else
39+
echo "is_prerelease=false" >> $GITHUB_OUTPUT
40+
echo "prerelease_tag=" >> $GITHUB_OUTPUT
41+
fi
42+
3243
build-image:
3344
needs: extract-version
3445
strategy:
@@ -62,9 +73,10 @@ jobs:
6273
images: |
6374
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
6475
tags: |
65-
type=sha,suffix=-${{ matrix.arch }}
6676
type=raw,value=${{ needs.extract-version.outputs.version }},suffix=-${{ matrix.arch }}
67-
type=raw,value=latest,suffix=-${{ matrix.arch }}
77+
type=raw,value=${{ needs.extract-version.outputs.prerelease_tag }},suffix=-${{ matrix.arch }},enable=${{ needs.extract-version.outputs.is_prerelease == 'true' }}
78+
type=raw,value=latest,suffix=-${{ matrix.arch }},enable=${{ needs.extract-version.outputs.is_prerelease == 'false' }}
79+
type=sha,suffix=-${{ matrix.arch }}
6880
6981
- name: Log in to the Container registry
7082
uses: docker/login-action@v3
@@ -102,15 +114,25 @@ jobs:
102114
username: ${{ github.actor }}
103115
password: ${{ secrets.GITHUB_TOKEN }}
104116

105-
- name: Create and push manifest images (latest)
117+
- name: Create and push manifest images
106118
uses: Noelware/docker-manifest-action@v1
107119
with:
108-
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
109-
inputs: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64
120+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.extract-version.outputs.version }}
121+
inputs: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.extract-version.outputs.version }}-amd64,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.extract-version.outputs.version }}-arm64
110122
push: true
111123

112-
- name: Create and push manifest images
124+
- name: Create and push manifest images (prerelease tag)
125+
if: needs.extract-version.outputs.is_prerelease == 'true'
113126
uses: Noelware/docker-manifest-action@v1
114127
with:
115-
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.extract-version.outputs.version }}
116-
inputs: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.extract-version.outputs.version }}-amd64,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.extract-version.outputs.version }}-arm64
128+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.extract-version.outputs.prerelease_tag }}
129+
inputs: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.extract-version.outputs.prerelease_tag }}-amd64,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.extract-version.outputs.prerelease_tag }}-arm64
130+
push: true
131+
132+
- name: Create and push manifest images (latest)
133+
if: needs.extract-version.outputs.is_prerelease == 'false'
134+
uses: Noelware/docker-manifest-action@v1
135+
with:
136+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
137+
inputs: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64
138+
push: true

0 commit comments

Comments
 (0)