Selaa lähdekoodia

fix: validate pushed tags before release build

copilot-swe-agent[bot] 3 kuukautta sitten
vanhempi
commit
342ea2dc0e
2 muutettua tiedostoa jossa 8 lisäystä ja 1 poistoa
  1. 7 0
      .github/workflows/release.yml
  2. 1 1
      OpenPuck/webusb_config.cpp

+ 7 - 0
.github/workflows/release.yml

@@ -60,6 +60,8 @@ jobs:
   build-release:
     if: github.event_name == 'release' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
     runs-on: ubuntu-latest
+    env:
+      SEMVER_RE: '^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$'
 
     steps:
       - name: Check out repository
@@ -67,6 +69,11 @@ jobs:
         with:
           fetch-depth: 0
 
+      - name: Validate pushed tag is semver
+        if: github.event_name == 'push'
+        run: |
+          echo "${GITHUB_REF_NAME}" | grep -Eq "${SEMVER_RE}"
+
       - name: Resolve release version
         id: release_version
         run: |

+ 1 - 1
OpenPuck/webusb_config.cpp

@@ -117,7 +117,7 @@ static void webusbSendBlob()
 	memset(&p[41], 0, 12); // 12B ASCII build ID, NUL-padded
 	{
 		const char *buildId = OPK_BUILD_VERSION;
-		if (!buildId || buildId[0] == '\0')
+		if (buildId[0] == '\0')
 			buildId = OPK_GIT_HASH;
 		for (uint8_t i = 0; i < 12 && buildId[i]; i++)
 			p[41 + i] = (uint8_t)buildId[i];