-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add calver, update submodule, let build wait for tagging
- Loading branch information
Showing
3 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,14 @@ jobs: | |
with: | ||
string: ${{ env.TAG }} | ||
|
||
- name: Wait for tagging to succeed | ||
uses: lewagon/[email protected] | ||
with: | ||
ref: ${{ github.ref }} | ||
check-name: 'Tag revision' | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
wait-interval: 10 | ||
|
||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
with: | ||
|
@@ -63,13 +71,52 @@ jobs: | |
type=ref,event=tag,priority=300 | ||
type=raw,priority=150,value=latest,enable={{is_default_branch}} | ||
# Retrieve all repository tags from the GitHub API using undocumented API call to get all tags | ||
# https://github.com/actions/github-script | ||
- name: Get all tags | ||
id: all-tags | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
return github.rest.repos.listTags({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
per_page: 100 | ||
}) | ||
# Prepare JSON output for Unix command line | ||
# https://github.com/mad9000/actions-find-and-replace-string | ||
- name: Format jq result | ||
id: formatted-jq | ||
uses: mad9000/actions-find-and-replace-string@2 | ||
with: | ||
source: ${{ steps.all-tags.outputs.result }} | ||
find: "'" | ||
replace: "\\'" | ||
|
||
# Parse Github API output and search for tags only matching the current commit SHA | ||
- name: Search all tags for commit | ||
id: tag-results | ||
run: | | ||
tags=$( echo '${{ steps.formatted-jq.outputs.value }}' | jq -r ".data | .[] | select( .commit.sha == \"${{ github.sha }}\" ) | .name" | tr '\n' ' ' ) | ||
echo "tags=${tags}" >> $GITHUB_OUTPUT | ||
# Merge the tag lists from docker/metadata-action and GitHub API | ||
- name: Build tag list | ||
id: tag-list | ||
run: | | ||
echo ::set-output name=tags::"$( | ||
echo -n "${{ steps.meta.outputs.tags }}" | tr '\n' ',' | ||
for r in `echo "${{ steps.tag-results.outputs.tags }}" | tr '\n' ' '`; do echo -n ,${{ steps.registry.outputs.lowercase }}${{ steps.image.outputs.lowercase }}:$r | tr '[:upper:]' '[:lower:]'; done | ||
)" | ||
- name: Build Image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
builder: ${{ steps.buildx.outputs.name }} | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
tags: ${{ steps.tag-list.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: CalVer Tagging | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
variant: | ||
required: true | ||
description: Variant tag to pass to CalVer | ||
type: string | ||
push: | ||
branches: | ||
- "**" | ||
tags: | ||
- "!**" | ||
concurrency: tag-scripts | ||
jobs: | ||
apply: | ||
runs-on: ubuntu-latest | ||
name: Tag revision | ||
steps: | ||
- name: Version | ||
uses: acrois/calver@trunk |