diff --git a/.github/workflows/test-release.yml b/.github/workflows/test-release.yml index 004d297..24d2947 100644 --- a/.github/workflows/test-release.yml +++ b/.github/workflows/test-release.yml @@ -20,15 +20,29 @@ jobs: - name: Install build deps run: sudo apt-get install -y devscripts debhelper build-essential + - name: Compute build version + id: version + run: | + BASE_VERSION=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/') + PR_NUMBER="${{ github.event.pull_request.number }}" + SHORT_SHA=$(git rev-parse --short HEAD) + BUILD_VERSION="${BASE_VERSION}+pr${PR_NUMBER}.${SHORT_SHA}" + echo "build_version=$BUILD_VERSION" >> "$GITHUB_OUTPUT" + echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT" + echo "Building version: $BUILD_VERSION" + - name: Inject version into PVEMod_Config.pm run: | - VERSION=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/') - SHORT_SHA=$(git rev-parse --short HEAD) - export BUILD_VERSION="${VERSION}-test-${SHORT_SHA}" + export BUILD_VERSION="${{ steps.version.outputs.build_version }}" perl -i -pe 'BEGIN { $v = $ENV{BUILD_VERSION} } s/(our \$VERSION\s*=\s*'"'"')[^'"'"']*'"'"';/$1'"'"'$v'"'"';/ ' src/PVENodeInfo/PVEMod_Config.pm + - name: Set package version in changelog + run: | + BUILD_VERSION="${{ steps.version.outputs.build_version }}" + sed -i -E "0,/\(([^)]*)\)/s//(${BUILD_VERSION})/" debian/changelog + - name: Build package run: dpkg-buildpackage -us -uc -b @@ -48,12 +62,10 @@ jobs: run: | mkdir -p artifacts cp ../*.deb artifacts/ - SHORT_SHA=$(git rev-parse --short HEAD) - echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT" - name: Upload deb as artifact uses: actions/upload-artifact@v4 with: - name: pve-mods-test-build-${{ steps.collect.outputs.short_sha }} + name: pve-mods-test-build-pr${{ github.event.pull_request.number }}-${{ steps.version.outputs.short_sha }} path: artifacts/*.deb retention-days: 3 \ No newline at end of file