1+ name : release
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ version :
7+ description : " The version to release"
8+ type : string
9+
10+ permissions :
11+ contents : write
12+ pull-requests : read
13+ statuses : write
14+ packages : write
15+
16+ jobs :
17+ release :
18+ name : release
19+ runs-on : ubuntu-latest
20+ timeout-minutes : 15
21+ outputs :
22+ has-changes : ${{ steps.check-changes.outputs.has-changes }}
23+ next-version : ${{ steps.next-version.outputs.NEXT_VERSION }}
24+ commit-hash : ${{ steps.auto-commit-action.outputs.commit_hash }}
25+ steps :
26+ - uses : actions/checkout@v6
27+ with :
28+ fetch-depth : 0
29+ - uses : jdx/mise-action@v3
30+ with :
31+ experimental : true
32+ - name : check for changes since last release
33+ id : check-changes
34+ run : |
35+ LAST_TAG=$(git tag -l | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1)
36+ if [ -z "$LAST_TAG" ]; then
37+ echo "No previous NetworkLayer releases found, will release"
38+ echo "has-changes=true" >> $GITHUB_OUTPUT
39+ else
40+ if [ -n "$(git diff --name-only ${LAST_TAG}..HEAD)" ]; then
41+ echo "NetworkLayer changes found since $LAST_TAG"
42+ echo "has-changes=true" >> $GITHUB_OUTPUT
43+ else
44+ echo "No NetworkLayer changes since $LAST_TAG"
45+ echo "has-changes=false" >> $GITHUB_OUTPUT
46+ fi
47+ fi
48+ - name : Get next version
49+ id : next-version
50+ if : steps.check-changes.outputs.has-changes == 'true'
51+ env :
52+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
53+ run : |
54+ NEXT_VERSION=$(git cliff --config ./cliff.toml --bumped-version)
55+ echo "NEXT_VERSION=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
56+ echo "Next NetworkLayer version will be: $NEXT_VERSION"
57+ - name : Update CHANGELOG.md
58+ if : steps.check-changes.outputs.has-changes == 'true'
59+ env :
60+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
61+ run : git cliff --config ./cliff.toml --bump -o ./CHANGELOG.md
62+ - name : Update README.md version
63+ if : steps.check-changes.outputs.has-changes == 'true'
64+ run : |
65+ sed -i -E 's|https://github.com/space-code/network-layer.git", from: "[0-9]+\.[0-9]+\.[0-9]+"|https://github.com/space-code/network-layer.git", from: "'"${{ steps.next-version.outputs.NEXT_VERSION }}"'"|g' README.md
66+ echo "Updated README.md with version ${{ steps.next-version.outputs.NEXT_VERSION }}"
67+ - name : Get release notes
68+ id : release-notes
69+ if : steps.check-changes.outputs.has-changes == 'true'
70+ env :
71+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
72+ run : |
73+ echo "RELEASE_NOTES<<EOF" >> "$GITHUB_OUTPUT"
74+
75+ echo "All notable changes to this project will be documented in this file." >> "$GITHUB_OUTPUT"
76+ echo "" >> "$GITHUB_OUTPUT"
77+ echo "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)," >> "$GITHUB_OUTPUT"
78+ echo "and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)." >> "$GITHUB_OUTPUT"
79+ echo "" >> "$GITHUB_OUTPUT"
80+
81+ git cliff --config ./cliff.toml --tag ${{ steps.next-version.outputs.NEXT_VERSION }} --unreleased --strip header | awk 'NF{p=1} p' | tail -n +2 >> "$GITHUB_OUTPUT"
82+
83+ echo "EOF" >> "$GITHUB_OUTPUT"
84+ - name : Commit changes
85+ id : auto-commit-action
86+ uses : stefanzweifel/git-auto-commit-action@v7
87+ if : steps.check-changes.outputs.has-changes == 'true'
88+ with :
89+ commit_options : " --allow-empty --no-verify"
90+ tagging_message : ${{ steps.next-version.outputs.NEXT_VERSION }}
91+ skip_dirty_check : true
92+ commit_message : " [Release] NetworkLayer ${{ steps.next-version.outputs.NEXT_VERSION }}"
93+ - name : Create GitHub Release
94+ uses : softprops/action-gh-release@v2
95+ if : steps.check-changes.outputs.has-changes == 'true'
96+ with :
97+ draft : false
98+ repository : space-code/network-layer
99+ name : ${{ steps.next-version.outputs.NEXT_VERSION }}
100+ tag_name : ${{ steps.next-version.outputs.NEXT_VERSION }}
101+ body : ${{ steps.release-notes.outputs.RELEASE_NOTES }}
102+ target_commitish : ${{ steps.auto-commit-action.outputs.commit_hash }}
103+
104+ docc :
105+ name : build and deploy docc
106+ runs-on : macos-latest
107+ needs : release
108+ if : ${{ needs.release.outputs.has-changes == 'true' }}
109+ timeout-minutes : 15
110+ steps :
111+ - uses : actions/checkout@v6
112+ with :
113+ ref : ${{ needs.release.outputs.commit-hash }}
114+ fetch-depth : 0
115+ - name : Build DocC
116+ id : build
117+ uses : space-code/build-docc@main
118+ with :
119+ schemes : ' ["NetworkLayer"]'
120+ version : ${{ needs.release.outputs.next-version }}
121+ - name : Generate Index Page
122+ uses : space-code/generate-index@v1.0.0
123+ with :
124+ version : ${{ needs.release.outputs.next-version }}
125+ project-name : ' NetworkLayer'
126+ project-description : ' NetworkLayer is a modern, lightweight Swift framework that provides elegant and robust retry policies for asynchronous operations.'
127+ modules : |
128+ [
129+ {
130+ "name": "NetworkLayer",
131+ "path": "networklayer",
132+ "description": "Core retry mechanisms and policies for asynchronous operations. Includes retry strategies, backoff algorithms, and cancellation support.",
133+ "badge": "Core Module"
134+ }
135+ ]
136+ - name : Deploy
137+ uses : peaceiris/actions-gh-pages@v4
138+ with :
139+ github_token : ${{ secrets.GITHUB_TOKEN }}
140+ publish_dir : ./docs
0 commit comments