@@ -123,3 +123,77 @@ jobs:
123123 done
124124 echo "Health check failed after 6 attempts"
125125 exit 1
126+
127+ auto-tag :
128+ name : Auto Tag & Release
129+ needs : deploy
130+ if : " github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '[skip ci]')"
131+ runs-on : ubuntu-latest
132+ permissions :
133+ contents : write
134+ steps :
135+ - uses : actions/checkout@v4
136+ with :
137+ token : ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
138+ fetch-depth : 0
139+
140+ - name : Setup Node
141+ uses : actions/setup-node@v4
142+ with :
143+ node-version : 22
144+
145+ - name : Bump version and push tag
146+ run : |
147+ TAURI_VER=$(node -p "require('./apps/desktop/src-tauri/tauri.conf.json').version")
148+ NPM_VER=$(node -p "require('./packages/openlinear/package.json').version")
149+
150+ get_latest_version() {
151+ local v1=$1
152+ local v2=$2
153+ if [ "$(printf '%s\n' "$v1" "$v2" | sort -V | tail -n1)" = "$v1" ]; then
154+ echo "$v1"
155+ else
156+ echo "$v2"
157+ fi
158+ }
159+
160+ HIGHEST=$(get_latest_version "$TAURI_VER" "$NPM_VER")
161+ IFS='.' read -ra ADDR <<< "$HIGHEST"
162+ MAJOR="${ADDR[0]}"
163+ MINOR="${ADDR[1]}"
164+ PATCH="${ADDR[2]}"
165+ NEW_PATCH=$((PATCH + 1))
166+ NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
167+
168+ echo "Bumping from $HIGHEST to $NEW_VERSION"
169+
170+ node -e "
171+ const fs = require('fs');
172+ const p = './packages/openlinear/package.json';
173+ const data = JSON.parse(fs.readFileSync(p));
174+ data.version = '$NEW_VERSION';
175+ fs.writeFileSync(p, JSON.stringify(data, null, 2) + '\n');
176+ "
177+
178+ node -e "
179+ const fs = require('fs');
180+ const p = './apps/desktop/src-tauri/tauri.conf.json';
181+ const data = JSON.parse(fs.readFileSync(p));
182+ data.version = '$NEW_VERSION';
183+ fs.writeFileSync(p, JSON.stringify(data, null, 2) + '\n');
184+ "
185+
186+ sed -i "s/^pkgver=.*/pkgver=$NEW_VERSION/" packaging/aur/openlinear-bin/PKGBUILD
187+ sed -i "s/pkgver = .*/pkgver = $NEW_VERSION/" packaging/aur/openlinear-bin/.SRCINFO
188+ sed -i "s/v$HIGHEST/v$NEW_VERSION/g" packaging/aur/openlinear-bin/.SRCINFO
189+ sed -i "s/openlinear-$HIGHEST/openlinear-$NEW_VERSION/g" packaging/aur/openlinear-bin/.SRCINFO
190+
191+ git config --global user.name "github-actions[bot]"
192+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
193+
194+ git add apps/desktop/src-tauri/tauri.conf.json packages/openlinear/package.json packaging/aur/openlinear-bin/PKGBUILD packaging/aur/openlinear-bin/.SRCINFO
195+ git commit -m "chore(release): v$NEW_VERSION [skip ci]"
196+ git tag "v$NEW_VERSION"
197+
198+ git push origin main
199+ git push origin "v$NEW_VERSION"
0 commit comments