Skip to content

Commit ee00d2b

Browse files
authored
fix(ci): Add missing update parameter to bump.sh with additional tests (#5284)
1 parent a73d5ff commit ee00d2b

File tree

3 files changed

+120
-6
lines changed

3 files changed

+120
-6
lines changed

.github/workflows/version-bump-util.yml

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,63 @@ on:
1919
- "./Sources/Configuration/Versioning.xcconfig"
2020
- "./Sources/Configuration/SentrySwiftUI.xcconfig"
2121
- "./Samples/Shared/Config/Versioning.xcconfig"
22+
- "./scripts/bump.sh"
2223

2324
jobs:
2425
run-version-bump:
25-
name: Run Version Bump
26+
# The release workflow uses the Makefile to bump the version so it needs to be tested.
27+
name: Run Version Bump (Makefile)
2628
# We intentionally run this on ubuntu because the release workflow also runs on ubuntu, which uses the version bump util.
2729
runs-on: ubuntu-latest
2830
steps:
2931
- uses: actions/checkout@v4
3032
- name: Generate Version Number
33+
id: generate-version-number
3134
run: |
3235
TIMESTAMP=$(date +%Y%m%d%H%M%S)
33-
echo "VERSION=100.0.$TIMESTAMP" >> $GITHUB_ENV
36+
echo "VERSION=100.0.$TIMESTAMP" >> $GITHUB_OUTPUT
3437
# We don't care which version we bump to, as long as it's a valid semver
35-
- run: make bump-version TO=${{ env.VERSION }}
36-
- run: make verify-version TO=${{ env.VERSION }}
38+
- run: make bump-version TO=${{ steps.generate-version-number.outputs.VERSION }}
39+
- run: make verify-version TO=${{ steps.generate-version-number.outputs.VERSION }}
40+
41+
run-version-bump-script:
42+
# Craft uses the shell script to bump the version so it needs to be tested.
43+
name: Run Version Bump (Shell Script)
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
- name: Generate Version Number
48+
id: generate-version-number
49+
run: |
50+
OLD_VERSION=$(cat ./Sources/Configuration/Versioning.xcconfig | grep MARKETING_VERSION | cut -d '=' -f 2 | tr -d ' ')
51+
echo "Read old version: ${OLD_VERSION}"
52+
echo "OLD_VERSION=${OLD_VERSION}" >> $GITHUB_OUTPUT
53+
54+
NEW_VERSION="100.0.$(date +%Y%m%d%H%M%S)"
55+
echo "Generated new version: ${NEW_VERSION}"
56+
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_OUTPUT
57+
58+
- name: Verify OLD_VERSION is defined
59+
if: ${{ steps.generate-version-number.outputs.OLD_VERSION == '' }}
60+
run: |
61+
echo "OLD_VERSION is not defined. Make sure this script is reading the version from the correct file."
62+
exit 1
63+
64+
- name: Create fake xcframework for update-package-sha.sh
65+
run: |
66+
mkdir -p Carthage
67+
echo "<FAKE STATIC ZIP>" > Carthage/Sentry.xcframework.zip
68+
echo "<FAKE DYNAMIC ZIP>" > Carthage/Sentry-Dynamic.xcframework.zip
69+
70+
- name: Bump version
71+
run: ./scripts/bump.sh ${{ steps.generate-version-number.outputs.OLD_VERSION }} ${{ steps.generate-version-number.outputs.NEW_VERSION }}
72+
73+
- name: Verify outputs of bump.sh
74+
run: make verify-version TO=${{ steps.generate-version-number.outputs.NEW_VERSION }}
75+
76+
- name: Verify outputs of update-package-sha.sh
77+
run: |
78+
./scripts/verify-package-sha.sh \
79+
--static-checksum "7062a80f8a80f8b6d812698af87384751567a6aaa0df6f03b0596d728b22dcfd" \
80+
--dynamic-checksum "f6325cd8f05523d60222451fa61b3cd3d58148e5a21236f82abfd3f92750c87c" \
81+
--last-release-runid "${{ github.run_id }}"

scripts/bump.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -eux
3-
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
44
cd "$SCRIPT_DIR/.."
55

66
OLD_VERSION="${1}"
@@ -10,6 +10,6 @@ echo "--> Clean VersionBump"
1010
cd Utils/VersionBump && swift build
1111
cd "$SCRIPT_DIR/.."
1212
echo "--> Bumping version to ${OLD_VERSION} ${NEW_VERSION}"
13-
./Utils/VersionBump/.build/debug/VersionBump "${NEW_VERSION}"
13+
./Utils/VersionBump/.build/debug/VersionBump --update "${NEW_VERSION}"
1414

1515
./scripts/update-package-sha.sh

scripts/verify-package-sha.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# This script is used to verify the checksum of the static and dynamic xcframeworks in Package.swift
5+
# and the last-release-runid in .github/last-release-runid.
6+
# It is used to verify the outputs of the update-package-sha.sh script.
7+
8+
# Parse command line arguments
9+
EXPECTED_STATIC_CHECKSUM=""
10+
EXPECTED_DYNAMIC_CHECKSUM=""
11+
EXPECTED_LAST_RELEASE_RUNID=""
12+
13+
while [[ $# -gt 0 ]]; do
14+
case $1 in
15+
--static-checksum)
16+
EXPECTED_STATIC_CHECKSUM="$2"
17+
shift 2
18+
;;
19+
--dynamic-checksum)
20+
EXPECTED_DYNAMIC_CHECKSUM="$2"
21+
shift 2
22+
;;
23+
--last-release-runid)
24+
EXPECTED_LAST_RELEASE_RUNID="$2"
25+
shift 2
26+
;;
27+
*)
28+
echo "Unknown option: $1"
29+
exit 1
30+
;;
31+
esac
32+
done
33+
34+
# Validate required arguments
35+
if [ -z "$EXPECTED_STATIC_CHECKSUM" ]; then
36+
echo "Error: --static-checksum is required"
37+
exit 1
38+
fi
39+
40+
if [ -z "$EXPECTED_DYNAMIC_CHECKSUM" ]; then
41+
echo "Error: --dynamic-checksum is required"
42+
exit 1
43+
fi
44+
45+
if [ -z "$EXPECTED_LAST_RELEASE_RUNID" ]; then
46+
echo "Error: --last-release-runid is required"
47+
exit 1
48+
fi
49+
50+
echo "Verify checksum of static xcframework in Package.swift"
51+
UPDATED_PACKAGE_SHA=$(grep "checksum.*Sentry-Static" Package.swift | cut -d '"' -f 2)
52+
if [ "$UPDATED_PACKAGE_SHA" != "$EXPECTED_STATIC_CHECKSUM" ]; then
53+
echo "::error::Expected checksum to be $EXPECTED_STATIC_CHECKSUM but got $UPDATED_PACKAGE_SHA"
54+
exit 1
55+
fi
56+
57+
echo "Verify checksum of dynamic xcframework in Package.swift"
58+
UPDATED_PACKAGE_SHA=$(grep "checksum.*Sentry-Dynamic" Package.swift | cut -d '"' -f 2)
59+
if [ "$UPDATED_PACKAGE_SHA" != "$EXPECTED_DYNAMIC_CHECKSUM" ]; then
60+
echo "::error::Expected checksum to be $EXPECTED_DYNAMIC_CHECKSUM but got $UPDATED_PACKAGE_SHA"
61+
exit 1
62+
fi
63+
64+
echo "Verify last-release-runid"
65+
LAST_RELEASE_RUNID=$(cat .github/last-release-runid)
66+
if [ "$LAST_RELEASE_RUNID" != "$EXPECTED_LAST_RELEASE_RUNID" ]; then
67+
echo "::error::Expected last-release-runid to be $EXPECTED_LAST_RELEASE_RUNID but got $LAST_RELEASE_RUNID"
68+
exit 1
69+
fi

0 commit comments

Comments
 (0)