-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (69 loc) · 2.65 KB
/
Copy pathcreate-release.yaml
File metadata and controls
79 lines (69 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Create Release
on:
push:
branches:
- main
jobs:
release:
name: Create GitHub release and tag
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Generate app token
id: app-token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
with:
client-id: ${{ secrets.FRAGFORCE_AUTOMATION_APP_ID }}
private-key: ${{ secrets.FRAGFORCE_AUTOMATION_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Extract version
id: version
run: |
VERSION=$(grep '^version = ' pyproject.toml | cut -d'"' -f2)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
- name: Check if tag exists
id: tag-check
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, skipping release"
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "Tag $TAG does not exist, creating release"
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Extract changelog
if: steps.tag-check.outputs.exists == 'false'
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
# Extract changelog section for this version (from version header to next version header or EOF)
awk "/^## \[$VERSION\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md > changelog.txt
echo "### Release Notes for $VERSION" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
cat changelog.txt >> "$GITHUB_STEP_SUMMARY"
- name: Create GitHub release
if: steps.tag-check.outputs.exists == 'false'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
TAG: ${{ steps.version.outputs.tag }}
VERSION: ${{ steps.version.outputs.version }}
run: |
gh release create "$TAG" \
--title "Release $VERSION" \
--notes-file changelog.txt \
--target "${{ github.sha }}"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "✅ Created release $TAG" >> "$GITHUB_STEP_SUMMARY"
- name: Skip summary
if: steps.tag-check.outputs.exists == 'true'
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
echo "### Release Skipped" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "Tag $TAG already exists" >> "$GITHUB_STEP_SUMMARY"