Skip to content

Commit 698c791

Browse files
authored
Handle missing tags gracefully (#20)
1 parent a73e005 commit 698c791

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

.github/workflows/ci-build.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ on:
1717
required: false
1818
type: boolean
1919
default: false
20+
rc:
21+
description: 'Tag image as rc'
22+
required: false
23+
type: boolean
24+
default: false
2025
workflow_dispatch:
2126

2227
name: ci-build
@@ -145,6 +150,7 @@ jobs:
145150
tags: |
146151
type=raw,value={{branch}},enable=${{ github.ref_type == 'branch' && github.event_name != 'pull_request' }}
147152
type=raw,value=latest,enable=${{ inputs.latest || false }}
153+
type=raw,value=rc,enable=${{ inputs.rc || false }}
148154
type=ref,event=branch
149155
type=ref,event=pr
150156
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
@@ -156,7 +162,7 @@ jobs:
156162
with:
157163
context: .
158164
file: Dockerfile
159-
push: ${{ inputs.latest || (github.ref_protected && github.event_name != 'pull_request') }}
165+
push: ${{ inputs.latest || inputs.rc || (github.ref_protected && github.event_name != 'pull_request') }}
160166
tags: ${{ steps.meta.outputs.tags }}
161167
labels: ${{ steps.meta.outputs.labels }}
162168
platforms: ${{ inputs.platforms || 'linux/amd64' }}
@@ -194,4 +200,4 @@ jobs:
194200
name: OpenShock Desktop Photino Linux
195201
path: publish/Photino-Linux/*
196202
retention-days: 7
197-
if-no-files-found: error
203+
if-no-files-found: error

.github/workflows/ci-tag.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,37 @@ jobs:
1818
- name: Find latest tag
1919
id: latest-tag
2020
uses: oprypin/find-latest-tag@v1
21+
continue-on-error: true
2122
with:
2223
repository: ${{ github.repository }}
23-
regex: '^\d+\.\d+\.\d+(-[0-9A-Za-z]+(\.\d+)*)?$'
24+
# Ignore preview or RC tags when searching for the latest
25+
regex: '^\d+\.\d+\.\d+$'
2426
releases-only: false
2527
- name: Set output
2628
run: echo "latest-tag=${{ steps.latest-tag.outputs.tag }}"
2729

30+
# Pre-job to find the latest RC tag
31+
get-latest-rc-tag:
32+
runs-on: ubuntu-latest
33+
outputs:
34+
latest-rc: ${{ steps.latest-rc.outputs.tag }}
35+
steps:
36+
- name: Find latest RC tag
37+
id: latest-rc
38+
uses: oprypin/find-latest-tag@v1
39+
continue-on-error: true
40+
with:
41+
repository: ${{ github.repository }}
42+
regex: '^\d+\.\d+\.\d+-rc\.\d+$'
43+
releases-only: false
44+
- name: Set output
45+
run: echo "latest-rc=${{ steps.latest-rc.outputs.tag }}"
46+
2847
# Delegate building and containerizing to a single workflow.
2948
build:
30-
needs: get-latest-tag
49+
needs: [get-latest-tag, get-latest-rc-tag]
3150
uses: ./.github/workflows/ci-build.yml
3251
with:
3352
platforms: linux/amd64,linux/arm64
34-
latest: ${{ needs.get-latest-tag.outputs.latest-tag == github.ref_name }}
53+
latest: ${{ needs.get-latest-tag.outputs.latest-tag == github.ref_name }}
54+
rc: ${{ needs.get-latest-rc-tag.outputs.latest-rc == github.ref_name }}

0 commit comments

Comments
 (0)