1111 push :
1212 branches : [livekit]
1313
14- env :
15- # We perform a dry run for all events except releases.
16- # This is to help make sure that we notice if the packaging process has become
17- # broken ahead of a release.
18- DRY_RUN : ${{ github.event_name != 'release' }}
19- # We should only use the hard coded test value for a dry run
20- VERSION : ${{ github.event_name == 'release' && github.event.release.tag_name || 'v0.0.0-pre.0' }}
21-
2214jobs :
15+ versioning :
16+ name : Versioning
17+ runs-on : ubuntu-latest
18+ outputs :
19+ DRY_RUN : ${{ steps.dry_run.outputs.DRY_RUN }}
20+ PREFIXED_VERSION : ${{ steps.prefixed_version.outputs.PREFIXED_VERSION }}
21+ UNPREFIXED_VERSION : ${{ steps.unprefixed_version.outputs.UNPREFIXED_VERSION }}
22+ TAG : ${{ steps.tag.outputs.TAG }}
23+ steps :
24+ - name : Calculate VERSION
25+ # We should only use the hard coded test value for a dry run
26+ run : echo "VERSION=${{ github.event_name == 'release' && github.event.release.tag_name || 'v0.0.0-pre.0' }}" >> "$GITHUB_ENV"
27+ - id : dry_run
28+ name : Set DRY_RUN
29+ # We perform a dry run for all events except releases.
30+ # This is to help make sure that we notice if the packaging process has become
31+ # broken ahead of a release.
32+ run : echo "DRY_RUN=${{ github.event_name != 'release' }}" >> "$GITHUB_OUTPUT"
33+ - id : prefixed_version
34+ name : Set PREFIXED_VERSION
35+ run : echo "PREFIXED_VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
36+ - id : unprefixed_version
37+ name : Set UNPREFIXED_VERSION
38+ # This just strips the leading character
39+ run : echo "UNPREFIXED_VERSION=${VERSION:1}" >> "$GITHUB_OUTPUT"
40+ - id : tag
41+ # latest = a proper release
42+ # other = anything else
43+ name : Set tag
44+ run : |
45+ if [[ "${VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
46+ echo "TAG=latest" >> "$GITHUB_OUTPUT"
47+ else
48+ echo "TAG=other" >> "$GITHUB_OUTPUT"
49+ fi
50+
2351 build_element_call :
52+ needs : versioning
2453 uses : ./.github/workflows/build-element-call.yaml
2554 with :
26- vite_app_version : embedded-${{ github.event.release.tag_name || 'v0.0.0-pre.0' }} # Using ${{ env.VERSION }} here doesn't work
55+ vite_app_version : embedded-${{ needs.versioning.outputs.PREFIXED_VERSION }}
2756 package : embedded
2857 secrets :
2958 SENTRY_ORG : ${{ secrets.SENTRY_ORG }}
@@ -32,15 +61,15 @@ jobs:
3261 SENTRY_AUTH_TOKEN : ${{ secrets.SENTRY_AUTH_TOKEN }}
3362
3463 publish_tarball :
35- needs : build_element_call
64+ needs : [ build_element_call, versioning]
3665 if : always()
3766 name : Publish tarball
3867 runs-on : ubuntu-latest
3968 permissions :
4069 contents : write # required to upload release asset
4170 steps :
4271 - name : Determine filename
43- run : echo "FILENAME_PREFIX=element-call-embedded-${VERSION:1 }" >> "$GITHUB_ENV"
72+ run : echo "FILENAME_PREFIX=element-call-embedded-${{ needs.versioning.outputs.UNPREFIXED_VERSION } }" >> "$GITHUB_ENV"
4473 - name : 📥 Download built element-call artifact
4574 uses : actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4
4675 with :
@@ -53,18 +82,20 @@ jobs:
5382 - name : Create Checksum
5483 run : find ${{ env.FILENAME_PREFIX }} -type f -print0 | sort -z | xargs -0 sha256sum | tee ${{ env.FILENAME_PREFIX }}.sha256
5584 - name : Upload
56- if : ${{ env .DRY_RUN == 'false' }}
85+ if : ${{ needs.versioning.outputs .DRY_RUN == 'false' }}
5786 uses : softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2
5887 with :
5988 files : |
6089 ${{ env.FILENAME_PREFIX }}.tar.gz
6190 ${{ env.FILENAME_PREFIX }}.sha256
6291
6392 publish_npm :
64- needs : build_element_call
93+ needs : [ build_element_call, versioning]
6594 if : always()
6695 name : Publish NPM
6796 runs-on : ubuntu-latest
97+ outputs :
98+ ARTIFACT_VERSION : ${{ steps.artifact_version.outputs.ARTIFACT_VERSION }}
6899 permissions :
69100 contents : read
70101 id-token : write # required for the provenance flag on npm publish
@@ -90,17 +121,23 @@ jobs:
90121 - name : Publish npm
91122 working-directory : embedded/web
92123 run : |
93- npm version ${{ env.VERSION }} --no-git-tag-version
124+ npm version ${{ needs.versioning.outputs.PREFIXED_VERSION }} --no-git-tag-version
94125 echo "ARTIFACT_VERSION=$(jq '.version' --raw-output package.json)" >> "$GITHUB_ENV"
95- npm publish --provenance --access public ${{ env .DRY_RUN == 'true' && '--dry-run' || '' }}
126+ npm publish --provenance --access public --tag ${{ needs.versioning.outputs.TAG }} ${{ needs.versioning.outputs .DRY_RUN == 'true' && '--dry-run' || '' }}
96127 env :
97128 NODE_AUTH_TOKEN : ${{ secrets.NPM_RELEASE_TOKEN }}
98129
130+ - id : artifact_version
131+ name : Output artifact version
132+ run : echo "ARTIFACT_VERSION=${{env.ARTIFACT_VERSION}}" >> "$GITHUB_OUTPUT"
133+
99134 publish_android :
100- needs : build_element_call
135+ needs : [ build_element_call, versioning]
101136 if : always()
102137 name : Publish Android AAR
103138 runs-on : ubuntu-latest
139+ outputs :
140+ ARTIFACT_VERSION : ${{ steps.artifact_version.outputs.ARTIFACT_VERSION }}
104141 permissions :
105142 contents : read
106143 steps :
@@ -122,7 +159,13 @@ jobs:
122159 java-version : " 17"
123160
124161 - name : Get artifact version
125- run : echo "ARTIFACT_VERSION=${VERSION:1}" >> "$GITHUB_ENV"
162+ # Anything that is not a final release will be tagged as a snapshot
163+ run : |
164+ if [[ "${{ needs.versioning.outputs.TAG }}" == "latest" ]]; then
165+ echo "ARTIFACT_VERSION=${{ needs.versioning.outputs.UNPREFIXED_VERSION }}" >> "$GITHUB_ENV"
166+ else
167+ echo "ARTIFACT_VERSION=${{ needs.versioning.outputs.UNPREFIXED_VERSION }}-SNAPSHOT" >> "$GITHUB_ENV"
168+ fi
126169
127170 - name : Set version string
128171 run : sed -i "s/0.0.0/${{ env.ARTIFACT_VERSION }}/g" embedded/android/lib/src/main/kotlin/io/element/android/call/embedded/Version.kt
@@ -135,13 +178,19 @@ jobs:
135178 ORG_GRADLE_PROJECT_mavenCentralPassword : ${{ secrets.MAVEN_RELEASE_PASSWORD }}
136179 ORG_GRADLE_PROJECT_signingInMemoryKey : ${{ secrets.GPG_SIGNING_KEY }}
137180 ORG_GRADLE_PROJECT_signingInMemoryKeyPassword : ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
138- run : ./gradlew publishAndReleaseToMavenCentral --no-daemon ${{ env.DRY_RUN == 'true' && '--dry-run' || '' }}
181+ run : ./gradlew publishToMavenCentral --no-daemon ${{ needs.versioning.outputs.DRY_RUN == 'true' && '--dry-run' || '' }}
182+
183+ - id : artifact_version
184+ name : Output artifact version
185+ run : echo "ARTIFACT_VERSION=${{env.ARTIFACT_VERSION}}" >> "$GITHUB_OUTPUT"
139186
140187 publish_ios :
141- needs : build_element_call
188+ needs : [ build_element_call, versioning]
142189 if : always()
143190 name : Publish SwiftPM Library
144191 runs-on : ubuntu-latest
192+ outputs :
193+ ARTIFACT_VERSION : ${{ steps.artifact_version.outputs.ARTIFACT_VERSION }}
145194 permissions :
146195 contents : read
147196 steps :
@@ -169,7 +218,7 @@ jobs:
169218 run : rsync -a --delete --exclude .git element-call/embedded/ios/ element-call-swift
170219
171220 - name : Get artifact version
172- run : echo "ARTIFACT_VERSION=${VERSION:1 }" >> "$GITHUB_ENV"
221+ run : echo "ARTIFACT_VERSION=${{ needs.versioning.outputs.UNPREFIXED_VERSION } }" >> "$GITHUB_ENV"
173222
174223 - name : Set version string
175224 run : sed -i "s/0.0.0/${{ env.ARTIFACT_VERSION }}/g" element-call-swift/Sources/EmbeddedElementCall/EmbeddedElementCall.swift
@@ -184,27 +233,33 @@ jobs:
184233 git config --global user.email "[email protected] " 185234 git config --global user.name "Element CI"
186235 git add -A
187- git commit -am "Release ${{ env.VERSION }}"
236+ git commit -am "Release ${{ needs.versioning.outputs.PREFIXED_VERSION }}"
188237 git tag -a ${{ env.ARTIFACT_VERSION }} -m "${{ github.event.release.html_url }}"
189238
190239 - name : Push
191240 working-directory : element-call-swift
192241 run : |
193- git push --tags ${{ env.DRY_RUN == 'true' && '--dry-run' || '' }}
242+ git push --tags ${{ needs.versioning.outputs.DRY_RUN == 'true' && '--dry-run' || '' }}
243+
244+ - id : artifact_version
245+ name : Output artifact version
246+ run : echo "ARTIFACT_VERSION=${{env.ARTIFACT_VERSION}}" >> "$GITHUB_OUTPUT"
194247
195248 release_notes :
196- needs : [publish_npm, publish_android, publish_ios]
249+ needs : [versioning, publish_npm, publish_android, publish_ios]
197250 if : always()
198251 name : Update release notes
199252 runs-on : ubuntu-latest
200253 permissions :
201254 contents : write # to update release notes
202255 steps :
203- - name : Get artifact version
204- run : echo "ARTIFACT_VERSION=${VERSION:1}" >> "$GITHUB_ENV"
205-
256+ - name : Log versions
257+ run : |
258+ echo "NPM: ${{ needs.publish_npm.outputs.ARTIFACT_VERSION }}"
259+ echo "Android: ${{ needs.publish_android.outputs.ARTIFACT_VERSION }}"
260+ echo "iOS: ${{ needs.publish_ios.outputs.ARTIFACT_VERSION }}"
206261 - name : Add release notes
207- if : ${{ env .DRY_RUN == 'false' }}
262+ if : ${{ needs.versioning.outputs .DRY_RUN == 'false' }}
208263 uses : softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2
209264 with :
210265 append_body : true
@@ -218,19 +273,19 @@ jobs:
218273 ### NPM
219274
220275 ```
221- npm install @element-hq/element-call-embedded@${{ env .ARTIFACT_VERSION }}
276+ npm install @element-hq/element-call-embedded@${{ needs.publish_npm.outputs .ARTIFACT_VERSION }}
222277 ```
223278
224279 ### Android AAR
225280
226281 ```
227282 dependencies {
228- implementation 'io.element.android:element-call-embedded:${{ env .ARTIFACT_VERSION }}'
283+ implementation 'io.element.android:element-call-embedded:${{ needs.publish_android.outputs .ARTIFACT_VERSION }}'
229284 }
230285 ```
231286
232287 ### SwiftPM
233288
234289 ```
235- .package(url: "https://github.com/element-hq/element-call-swift.git", from: "${{ env .ARTIFACT_VERSION }}")
290+ .package(url: "https://github.com/element-hq/element-call-swift.git", from: "${{ needs.publish_ios.outputs .ARTIFACT_VERSION }}")
236291 ```
0 commit comments