Skip to content

Commit c467375

Browse files
committed
Update version without committing to main
1 parent 0c6b4e5 commit c467375

File tree

6 files changed

+70
-61
lines changed

6 files changed

+70
-61
lines changed

.github/workflows/release.yml

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
runs-on: ubuntu-latest
1010
environment: release-check
1111
steps:
12-
- name: Check For Admin Permission
12+
- name: Verify Admin Permission
1313
uses: actions-cool/check-user-permission@v2
1414
with:
1515
require: admin
1616
username: ${{ github.triggering_actor }}
1717

18-
- name: Check Repository
18+
- name: Verifying Release Workflow
1919
run: |
2020
if [ "${{ vars.RUN_RELEASE_BUILDS }}" = "1" ]; then
2121
MSG="Running workflow because RUN_RELEASE_BUILDS=1"
@@ -38,7 +38,7 @@ jobs:
3838
echo "${MSG}" >> "${GITHUB_STEP_SUMMARY}"
3939
fi
4040
41-
- name: Check Branch
41+
- name: Verifying Branch
4242
run: |
4343
echo "Trying to run the release workflow from branch ${{ github.ref_name }}"
4444
if [ "${{ github.ref_name }}" != "main" ]; then
@@ -50,7 +50,7 @@ jobs:
5050
fi
5151
5252
update-main:
53-
name: Update CHANGELOG.md and linux/svtminion.sh windows/svtminion.ps1
53+
name: Prepare Files for Release
5454
runs-on: ubuntu-latest
5555
permissions:
5656
contents: write # To be able to publish the release
@@ -146,19 +146,23 @@ jobs:
146146
CUT_RELEASE_VERSION=$(cat .cut_release_version)
147147
echo "CUT_RELEASE_VERSION=${CUT_RELEASE_VERSION}" >> "$GITHUB_ENV"
148148
149-
- name: Update linux/svtminion.sh sha256sum's
149+
- name: Prepare Release Artifacts
150150
run: |
151-
(cd linux && sha256sum svtminion.sh > ../svtminion.sh.sha256)
152-
(cd windows && sha256sum svtminion.ps1 > ../svtminion.ps1.sha256)
153-
git add svtminion.sh.sha256
154-
git add svtminion.ps1.sha256
155-
git commit --allow-empty -am "Update sha256 checksums" || git commit --allow-empty -am "Update sha256 checksums"
151+
# Move scripts to dist directory so we don't update the source files
152+
mkdir -p dist
153+
cp linux/svtminion.sh dist/svtminion.sh
154+
cp windows/svtminion.ps1 dist/svtminion.ps1
155+
# Inject release version into artifact copies via helper script
156+
python3 .github/workflows/scripts/update-svtminion-versions.py "${CUT_RELEASE_VERSION}"
157+
# Generate checksums for the release artifacts
158+
(cd dist && sha256sum svtminion.sh > ../svtminion.sh.sha256)
159+
(cd dist && sha256sum svtminion.ps1 > ../svtminion.ps1.sha256)
156160
157-
- name: Tag The ${{ needs.update-main.outputs.release-version }} Release
161+
- name: Create Tag: ${{ needs.update-main.outputs.release-version }}
158162
run: |
159163
git tag -f --no-sign -m "Release ${{ needs.update-main.outputs.release-version }}" -a ${{ needs.update-main.outputs.release-version }}
160164
161-
- name: Create Github Release
165+
- name: Create GitHub Release
162166
uses: softprops/action-gh-release@v1
163167
with:
164168
name: ${{ env.CUT_RELEASE_VERSION }}
@@ -169,8 +173,8 @@ jobs:
169173
prerelease: false
170174
generate_release_notes: false
171175
files: |
172-
linux/svtminion.sh
173-
windows/svtminion.ps1
176+
dist/svtminion.sh
177+
dist/svtminion.ps1
174178
svtminion.sh.sha256
175179
svtminion.ps1.sha256
176180
LICENSE
@@ -182,9 +186,10 @@ jobs:
182186
failOnError: false
183187

184188
update-main-checksums:
185-
name: Update Release Checksums on Main
189+
name: Update Release Checksums
186190
runs-on: ubuntu-latest
187191
needs:
192+
- update-main
188193
- publish-release
189194
environment: release
190195
permissions:
@@ -198,17 +203,6 @@ jobs:
198203
repository: ${{ github.repository }}
199204
ssh-key: ${{ secrets.SALT_VMTOOLS_RELEASE_KEY }}
200205

201-
- name: Get linux/svtminion.sh on main branch sha256sum
202-
run: |
203-
echo "SH=$(sha256sum linux/svtminion.sh | awk '{ print $1 }')" >> "$GITHUB_ENV"
204-
echo "VMTS_VERSION=$(bash linux/svtminion.sh --version | awk '{ print $1 }')" >> "$GITHUB_ENV"
205-
206-
- uses: actions/checkout@v6
207-
with:
208-
ref: main
209-
repository: ${{ github.repository }}
210-
ssh-key: ${{ secrets.SALT_VMTOOLS_RELEASE_KEY }}
211-
212206
- name: Configure Git
213207
shell: bash
214208
run: |
@@ -217,9 +211,13 @@ jobs:
217211
git config --global user.email saltproject.pdl@broadcom.com
218212
git config --global commit.gpgsign false
219213
220-
- name: Update Latest Release on README
214+
- name: Update Checksums in README.md
215+
shell: bash
221216
run: |
222-
python3 .github/workflows/scripts/update-release-shasum.py ${{ env.VMTS_VERSION }} ${{ env.SH }}
217+
VERSION="${{ needs.update-main.outputs['release-version'] }}"
218+
curl -sL "https://github.com/${{ github.repository }}/releases/download/${VERSION}/svtminion.sh" -o svtminion.sh
219+
SH="$(sha256sum svtminion.sh | awk '{ print $1 }')"
220+
python3 .github/workflows/scripts/update-release-shasum.py "$VERSION" "$SH"
223221
224222
- name: Show Changes
225223
run: |

.github/workflows/scripts/cut-release.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -188,37 +188,7 @@ def main():
188188
+ changelog_file.read_text()
189189
)
190190

191-
# Update Script Version for the bash script
192-
svtminion_script_path = REPO_ROOT / "linux/svtminion.sh"
193-
print(
194-
f"* Updating {svtminion_script_path.relative_to(REPO_ROOT)} ...",
195-
file=sys.stderr,
196-
flush=True,
197-
)
198-
svtminion_script_path.write_text(
199-
re.sub(
200-
r'readonly SCRIPT_VERSION="(.*)"',
201-
f'readonly SCRIPT_VERSION="{options.release_tag.lstrip("v")}"',
202-
svtminion_script_path.read_text(),
203-
)
204-
)
205-
206-
# Update the Script Version for the powershell script
207-
svtminion_script_path = REPO_ROOT / "windows/svtminion.ps1"
208-
print(
209-
f"* Updating {svtminion_script_path.relative_to(REPO_ROOT)} ...",
210-
file=sys.stderr,
211-
flush=True,
212-
)
213-
svtminion_script_path.write_text(
214-
re.sub(
215-
r'\$SCRIPT_VERSION = "(.*)"',
216-
f'$SCRIPT_VERSION = "{options.release_tag.lstrip("v")}"',
217-
svtminion_script_path.read_text(),
218-
)
219-
)
220-
221-
parser.exit(status=0, message="CHANGELOG.md and svtminion.sh updated\n")
191+
parser.exit(status=0, message="CHANGELOG.md and release metadata updated\n")
222192

223193

224194
if __name__ == "__main__":

.github/workflows/scripts/update-release-shasum.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010

1111
def main(version, sha256sum):
12+
# Normalize version tags like "v2026.03.16" to "2026.03.16"
13+
version = version.lstrip("v")
1214
in_contents = README_PATH.read_text()
1315
if version in in_contents:
1416
print(f"README file already contains an entry for version {version}")
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python
2+
import pathlib
3+
import re
4+
import sys
5+
6+
7+
def main():
8+
if len(sys.argv) != 2:
9+
raise SystemExit(f"Usage: {sys.argv[0]} <version>")
10+
11+
# Strip leading "v" from tags like "v2026.03.16"
12+
version = sys.argv[1].lstrip("v")
13+
14+
# These are the artifact copies created in the workflow
15+
linux_path = pathlib.Path("dist/svtminion.sh")
16+
windows_path = pathlib.Path("dist/svtminion.ps1")
17+
18+
# Update bash script readonly SCRIPT_VERSION
19+
linux_text = linux_path.read_text(encoding="utf-8")
20+
linux_text = re.sub(
21+
r'readonly SCRIPT_VERSION="(.*)"',
22+
f'readonly SCRIPT_VERSION="{version}"',
23+
linux_text,
24+
)
25+
linux_path.write_text(linux_text, encoding="utf-8")
26+
27+
# Update PowerShell script $SCRIPT_VERSION
28+
windows_text = windows_path.read_text(encoding="utf-8")
29+
windows_text = re.sub(
30+
r'\$SCRIPT_VERSION = "(.*)"',
31+
f'$SCRIPT_VERSION = "{version}"',
32+
windows_text,
33+
)
34+
windows_path.write_text(windows_text, encoding="utf-8")
35+
36+
37+
if __name__ == "__main__":
38+
main()
39+

linux/svtminion.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -o pipefail
1919
# using bash for now
2020
# run this script as root, as needed to run Salt
2121

22-
readonly SCRIPT_VERSION="2026.03.13"
22+
readonly SCRIPT_VERSION="SCRIPT_VERSION_REPLACE"
2323

2424
# definitions
2525

windows/svtminion.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ if ($help) {
287287
}
288288

289289
# This value is populated via CICD during build
290-
$SCRIPT_VERSION = "2026.03.13"
290+
$SCRIPT_VERSION = "SCRIPT_VERSION_REPLACE"
291291
if ($Version) {
292292
Write-Host $SCRIPT_VERSION
293293
exit 0

0 commit comments

Comments
 (0)