@@ -2,12 +2,8 @@ name: Docker
22
33on :
44 push :
5- branches :
6- - main
75 tags :
86 - " v*"
9- pull_request :
10- workflow_dispatch :
117
128env :
139 IMAGE_NAME : syscc/embypanel
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
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
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