Skip to content

Commit 0e42de6

Browse files
soso
authored andcommitted
Publish releases from version tags
1 parent 9d284cb commit 0e42de6

1 file changed

Lines changed: 35 additions & 6 deletions

File tree

.github/workflows/docker.yml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ name: Docker
22

33
on:
44
push:
5-
branches:
6-
- main
75
tags:
86
- "v*"
9-
pull_request:
10-
workflow_dispatch:
117

128
env:
139
IMAGE_NAME: syscc/embypanel
@@ -16,7 +12,7 @@ jobs:
1612
docker:
1713
runs-on: ubuntu-latest
1814
permissions:
19-
contents: read
15+
contents: write
2016
steps:
2117
- name: Checkout
2218
uses: actions/checkout@v4
@@ -33,7 +29,7 @@ jobs:
3329
with:
3430
images: ${{ env.IMAGE_NAME }}
3531
tags: |
36-
type=raw,value=latest,enable={{is_default_branch}}
32+
type=raw,value=latest
3733
type=ref,event=tag
3834
3935
- name: Check Docker Hub credentials
@@ -67,3 +63,36 @@ jobs:
6763
labels: ${{ steps.meta.outputs.labels }}
6864
cache-from: type=gha
6965
cache-to: type=gha,mode=max
66+
67+
- name: Extract release notes
68+
id: release_notes
69+
shell: bash
70+
run: |
71+
version="${GITHUB_REF_NAME}"
72+
notes_file="docs/changelog.md"
73+
output_file="${RUNNER_TEMP}/release-notes.md"
74+
awk -v version="$version" '
75+
$0 == "## " version { found=1; next }
76+
found && /^## / { exit }
77+
found { print }
78+
' "$notes_file" | sed '/./,$!d' > "$output_file"
79+
if [[ ! -s "$output_file" ]]; then
80+
{
81+
echo "## ${version}"
82+
echo
83+
echo "Docker images:"
84+
echo
85+
echo "- syscc/embypanel:${version}"
86+
echo "- syscc/embypanel:latest"
87+
} > "$output_file"
88+
fi
89+
echo "file=$output_file" >> "$GITHUB_OUTPUT"
90+
91+
- name: Publish GitHub Release
92+
env:
93+
GH_TOKEN: ${{ github.token }}
94+
run: |
95+
gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1 && mode=edit || mode=create
96+
gh release "$mode" "$GITHUB_REF_NAME" \
97+
--title "$GITHUB_REF_NAME" \
98+
--notes-file "${{ steps.release_notes.outputs.file }}"

0 commit comments

Comments
 (0)