Skip to content

Commit 03d871e

Browse files
Add GitHub Actions workflow for publishing draft releases
1 parent b366a33 commit 03d871e

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish draft release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repo
14+
uses: actions/checkout@v4
15+
16+
- name: Get latest draft release
17+
id: draft
18+
run: |
19+
draft_info=$(gh release list --limit 5 --json tagName,isDraft,publishedAt --jq '.[] | select(.isDraft==true) | .tagName' | head -n1)
20+
echo "tag_name=${draft_info}" >> $GITHUB_OUTPUT
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Validate draft version
25+
run: |
26+
if [ -z "${{ steps.draft.outputs.tag_name }}" ]; then
27+
echo "No draft release found!" >&2
28+
exit 1
29+
fi
30+
echo "Found draft version: ${{ steps.draft.outputs.tag_name }}"
31+
32+
- name: Write VERSION file
33+
run: |
34+
echo "${{ steps.draft.outputs.tag_name }}" | sed 's/^v//' > VERSION
35+
cat VERSION
36+
37+
- name: Commit VERSION file
38+
run: |
39+
git config user.name "github-actions[bot]"
40+
git config user.email "github-actions[bot]@users.noreply.github.com"
41+
git add VERSION
42+
git commit -m "chore: add VERSION ${{ steps.draft.outputs.tag_name }}" || echo "No changes to commit"
43+
git push
44+
45+
# - name: Create tag
46+
# run: |
47+
# git tag "${{ steps.draft.outputs.tag_name }}"
48+
# git push origin "${{ steps.draft.outputs.tag_name }}"
49+
#
50+
# - name: Publish draft release
51+
# run: gh release edit "${{ steps.draft.outputs.tag_name }}" --draft=false
52+
# env:
53+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)