Skip to content

Commit 798f081

Browse files
authored
feat: automated publishing (#207)
1 parent 356cfcf commit 798f081

File tree

2 files changed

+55
-81
lines changed

2 files changed

+55
-81
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- "v*"
9+
10+
permissions:
11+
contents: write
12+
id-token: write
13+
14+
jobs:
15+
release_gh:
16+
name: GitHub Release
17+
if: github.event_name == 'push' || (github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release'))
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: 📚 Git Checkout
21+
uses: actions/checkout@v6
22+
23+
- name: Get latest version
24+
run: |
25+
echo "PACKAGE_VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')" >> $GITHUB_ENV
26+
27+
- name: Download dSYMs
28+
if: github.event_name == 'pull_request'
29+
env:
30+
PR_BODY: ${{ github.event.pull_request.body }}
31+
run: |
32+
url=$(echo "$PR_BODY" | grep -oE 'https://[^ )]*dSYMs\.zip' | head -n 1)
33+
if [ -n "$url" ]; then
34+
echo "Found dSYMs URL: $url"
35+
curl -L -o dSYMs.zip "$url"
36+
else
37+
echo "No dSYMs.zip URL found in PR body."
38+
fi
39+
40+
- name: Generate Changelog
41+
run: awk '/^## \[/{if (f) exit; f=1; next} f' CHANGELOG.md > RELEASE_NOTES.md
42+
43+
- name: GitHub Release
44+
env:
45+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
run: |
47+
FILES=""
48+
if [ -f dSYMs.zip ]; then
49+
FILES="dSYMs.zip"
50+
fi
51+
gh release create v${{ env.PACKAGE_VERSION }} \
52+
--title "freeRASP ${{ env.PACKAGE_VERSION }}" \
53+
--notes-file RELEASE_NOTES.md \
54+
$FILES

.github/workflows/publish-release.yml

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,14 @@
11
name: Publish release
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
tags:
8-
- "v*"
4+
workflow_dispatch:
95

106
permissions:
11-
contents: write
127
id-token: write
138

149
jobs:
15-
check_release:
16-
name: Check release conditions
17-
runs-on: ubuntu-latest
18-
outputs:
19-
should_release: ${{ steps.check.outputs.should_release }}
20-
steps:
21-
- name: 📚 Git Checkout
22-
uses: actions/checkout@v6
23-
24-
- name: Check conditions
25-
id: check
26-
env:
27-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28-
run: |
29-
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
30-
echo "Proceeding with tag release"
31-
echo "should_release=true" >> $GITHUB_OUTPUT
32-
elif [[ "${{ github.ref }}" == refs/heads/master ]]; then
33-
# Find the PR associated with the merge commit that has 'release' label
34-
PR_COUNT=$(gh pr list --search "${{ github.sha }}" --state merged --label release --json number --jq 'length')
35-
if [[ "$PR_COUNT" -gt 0 ]]; then
36-
echo "Proceeding with release labeled PR"
37-
echo "should_release=true" >> $GITHUB_OUTPUT
38-
else
39-
echo "No release label found on merged PR, skipping."
40-
echo "should_release=false" >> $GITHUB_OUTPUT
41-
fi
42-
else
43-
echo "should_release=false" >> $GITHUB_OUTPUT
44-
fi
45-
46-
release_gh:
47-
name: GitHub Release
48-
needs: check_release
49-
if: needs.check_release.outputs.should_release == 'true'
50-
runs-on: ubuntu-latest
51-
steps:
52-
- name: 📚 Git Checkout
53-
uses: actions/checkout@v6
54-
55-
- name: Get latest version
56-
run: |
57-
echo "PACKAGE_VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')" >> $GITHUB_ENV
58-
59-
- name: Download dSYMs
60-
if: github.ref == 'refs/heads/master'
61-
env:
62-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63-
run: |
64-
PR_BODY=$(gh pr list --search "${{ github.sha }}" --state merged --json body --jq '.[0].body')
65-
url=$(echo "$PR_BODY" | grep -oE 'https://[^ )]*dSYMs\.zip' | head -n 1)
66-
if [ -n "$url" ]; then
67-
echo "Found dSYMs URL: $url"
68-
curl -L -o dSYMs.zip "$url"
69-
else
70-
echo "No dSYMs.zip URL found in PR body."
71-
fi
72-
73-
- name: Generate Changelog
74-
run: awk '/^## \[/{if (f) exit; f=1; next} f' CHANGELOG.md > RELEASE_NOTES.md
75-
76-
- name: GitHub Release
77-
env:
78-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79-
run: |
80-
FILES=""
81-
if [ -f dSYMs.zip ]; then
82-
FILES="dSYMs.zip"
83-
fi
84-
gh release create v${{ env.PACKAGE_VERSION }} \
85-
--title "freeRASP ${{ env.PACKAGE_VERSION }}" \
86-
--notes-file RELEASE_NOTES.md \
87-
$FILES || echo ""
88-
8910
publish_pub_dev:
9011
name: Publish release to pub.dev
91-
needs: release_gh
9212
runs-on: ubuntu-latest
9313
steps:
9414
- name: 📚 Git Checkout

0 commit comments

Comments
 (0)