Skip to content

Commit 6fa5a53

Browse files
committed
More changesets fixes
1 parent 36b5523 commit 6fa5a53

File tree

6 files changed

+189
-7
lines changed

6 files changed

+189
-7
lines changed

.github/workflows/changeset.yml

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,29 @@ jobs:
3333
- name: Install dependencies
3434
run: pnpm install
3535

36+
- name: Make PR title
37+
id: getver
38+
run: |
39+
pnpm ci:version
40+
echo "TITLE=v$(./scripts/get_version.sh)" >> "$GITHUB_OUTPUT"
41+
git restore .
42+
env:
43+
# requires repo and read:user access
44+
GITHUB_TOKEN: ${{ secrets.CHANGESET_GH_TOKEN }}
45+
3646
- name: Create Release Pull Request
3747
id: changesets
3848
uses: changesets/action@v1
3949
with:
50+
title: ${{ steps.getver.outputs.TITLE }}
51+
commit: ${{ steps.getver.outputs.TITLE }}
4052
version: pnpm ci:version
4153
publish: pnpm ci:publish
4254
env:
4355
GITHUB_TOKEN: ${{ secrets.CHANGESET_GH_TOKEN }}
4456
outputs:
45-
hasPublishedKotlin: ${{ steps.changesets.outputs.published == 'true' }}
57+
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
58+
hasPublished: ${{ steps.changesets.outputs.published == 'true' }}
4659

4760
debug-outputs:
4861
needs: release
@@ -51,13 +64,13 @@ jobs:
5164
steps:
5265
- name: "echo outputs"
5366
run: |
54-
echo ${{ steps.changesets.outputs.publishedPackages }}
55-
echo ${{ needs.release.outputs.hasPublishedKotlin }}
67+
echo ${{ needs.release.outputs.publishedPackages }}
68+
echo ${{ needs.release.outputs.hasPublished }}
5669
5770
publish-kotlin:
5871
needs: release
59-
name: Publish Android
60-
if: ${{ needs.release.outputs.hasPublishedKotlin == 'true' }}
72+
name: Publish Kotlin
73+
if: ${{ needs.release.outputs.hasPublished == 'true' }}
6174
runs-on: ubuntu-latest
6275
defaults:
6376
run:
@@ -102,4 +115,31 @@ jobs:
102115
run: ./gradlew publish
103116

104117
- name: Close and release to maven
105-
run: ./gradlew closeAndReleaseRepository
118+
run: ./gradlew closeAndReleaseRepository
119+
120+
update-snapshot:
121+
needs: release
122+
name: Update SNAPSHOT
123+
if: ${{ needs.release.outputs.hasPublished == 'true' }}
124+
runs-on: ubuntu-latest
125+
126+
steps:
127+
- name: Checkout Repo
128+
uses: actions/checkout@v4
129+
130+
- name: Update snapshot
131+
id: update
132+
run: echo "SNAPSHOT_VERSION=$(./scripts/update_snapshot_version.sh)" >> "$GITHUB_OUTPUT"
133+
134+
- name: Log version
135+
env:
136+
SNAPSHOT_VERSION: ${{ steps.update.outputs.SNAPSHOT_VERSION }}
137+
run: echo $SNAPSHOT_VERSION
138+
139+
- name: Create Update SNAPSHOT Pull Request
140+
uses: peter-evans/create-pull-request@v6
141+
with:
142+
token: ${{ secrets.CHANGESET_GH_TOKEN }}
143+
branch: dl/update_snapshot_ver
144+
title: Prepare snapshot version ${{ steps.update.outputs.SNAPSHOT_VERSION }}
145+
commit-message: Prepare snapshot version ${{ steps.update.outputs.SNAPSHOT_VERSION }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Manually create SNAPSHOT update PR
2+
3+
on:
4+
workflow_dispatch:
5+
6+
concurrency: ${{ github.workflow }}-${{ github.ref }}
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
update-snapshot:
14+
name: Update SNAPSHOT
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout Repo
19+
uses: actions/checkout@v4
20+
21+
- name: Update snapshot
22+
id: update
23+
run: echo "SNAPSHOT_VERSION=$(./ci/update_snapshot_version.sh)" >> "$GITHUB_OUTPUT"
24+
25+
- name: Log version
26+
env:
27+
SNAPSHOT_VERSION: ${{ steps.update.outputs.SNAPSHOT_VERSION }}
28+
run: echo $SNAPSHOT_VERSION
29+
30+
- name: Create Update SNAPSHOT Pull Request
31+
uses: peter-evans/create-pull-request@v6
32+
with:
33+
token: ${{ secrets.CHANGESET_GH_TOKEN }}
34+
branch: dl/update_snapshot_ver
35+
title: Prepare snapshot version ${{ steps.update.outputs.SNAPSHOT_VERSION }}
36+
commit-message: Prepare snapshot version ${{ steps.update.outputs.SNAPSHOT_VERSION }}

scripts/get_version.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
set -x
4+
5+
PACKAGE_VERSION=$(cat ./package.json | jq -r '.version')
6+
echo "$PACKAGE_VERSION"

scripts/increment_semver.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2014 Fritz Mahnke
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
# From: https://github.com/fmahnke/shell-semver/tree/master
24+
25+
#!/bin/bash
26+
27+
# Increment a version string using Semantic Versioning (SemVer) terminology.
28+
29+
# Parse command line options.
30+
31+
while getopts ":Mmp" Option
32+
do
33+
case $Option in
34+
M ) major=true;;
35+
m ) minor=true;;
36+
p ) patch=true;;
37+
esac
38+
done
39+
40+
shift $(($OPTIND - 1))
41+
42+
version=$1
43+
44+
# Build array from version string.
45+
46+
a=( ${version//./ } )
47+
48+
# If version string is missing or has the wrong number of members, show usage message.
49+
50+
if [ ${#a[@]} -ne 3 ]
51+
then
52+
echo "usage: $(basename $0) [-Mmp] major.minor.patch"
53+
exit 1
54+
fi
55+
56+
# Increment version numbers as requested.
57+
58+
if [ ! -z $major ]
59+
then
60+
((a[0]++))
61+
a[1]=0
62+
a[2]=0
63+
fi
64+
65+
if [ ! -z $minor ]
66+
then
67+
((a[1]++))
68+
a[2]=0
69+
fi
70+
71+
if [ ! -z $patch ]
72+
then
73+
((a[2]++))
74+
fi
75+
76+
echo "${a[0]}.${a[1]}.${a[2]}"

scripts/update_android_gradle_version.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ set -e
33
set -x
44

55
PACKAGE_VERSION=$(cat ./package.json | jq -r '.version')
6-
echo "updating gradle version name to $PACKAGE_VERSION"
6+
>&2 echo "updating gradle version name to $PACKAGE_VERSION"
7+
8+
SNAPSHOT_VERSION=$(./ci/increment_semver.sh -p $PACKAGE_VERSION)"-SNAPSHOT"
9+
>&2 echo "next snapshot version to $SNAPSHOT_VERSION"
10+
711
# sed command works only on linux based systems as macOS version expects a backup file passed additionally
812

913
if [ "$(uname)" == "Darwin" ]; then

scripts/update_snapshot_version.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -e
3+
set -x
4+
5+
PACKAGE_VERSION=$(cat ./package.json | jq -r '.version')
6+
>&2 echo "current version: $PACKAGE_VERSION"
7+
8+
SNAPSHOT_VERSION=$(./ci/increment_semver.sh -p $PACKAGE_VERSION)"-SNAPSHOT"
9+
>&2 echo "updating snapshot version to $SNAPSHOT_VERSION"
10+
11+
# sed command works only on linux based systems as macOS version expects a backup file passed additionally
12+
if [ "$(uname)" == "Darwin" ]; then
13+
ARGS=('')
14+
else
15+
ARGS=()
16+
fi
17+
18+
sed -i "${ARGS[@]}" -e "/VERSION_NAME=/ s/=.*/=$SNAPSHOT_VERSION/" ./gradle.properties
19+
20+
echo $SNAPSHOT_VERSION

0 commit comments

Comments
 (0)