diff --git a/.github/workflows/package_reusable.yaml b/.github/workflows/package_reusable.yaml index 7d623f8..e27953f 100644 --- a/.github/workflows/package_reusable.yaml +++ b/.github/workflows/package_reusable.yaml @@ -36,8 +36,43 @@ jobs: cargo aur cargo generate-rpm - # - name: check for publish - # run: cargo publish --dry-run --allow-dirty + - name: check for publish + run: | + # Function to add -dryRun to the version + add_dryrun_to_version() { + if [[ -f $CARGO_FILE ]]; then + # Backup the original Cargo.toml before modification + cp "$CARGO_FILE" "$BACKUP_FILE" + + # Extract the current version from the file + ORIGINAL_VERSION=$(grep -oP '^version\s*=\s*"\K[^\"]+' "$CARGO_FILE") + + if [[ -n $ORIGINAL_VERSION ]]; then + # Modify the version and write it back to the Cargo.toml file + sed -i "s/version = \"$ORIGINAL_VERSION\"/version = \"$ORIGINAL_VERSION-dryRun\"/" "$CARGO_FILE" + echo "Version modified to: $ORIGINAL_VERSION-dryRun" + else + echo "No version found in the file." + fi + else + echo "Cargo.toml file not found!" + fi + } + + # Function to revert the version to its original state by restoring from backup + revert_version() { + if [[ -f $BACKUP_FILE ]]; then + # Restore the original Cargo.toml from the backup + mv "$BACKUP_FILE" "$CARGO_FILE" + echo "Cargo.toml reverted to the original version." + else + echo "Backup file not found! Cannot revert." + fi + } + + add_dryrun_to_version + cargo publish --dry-run --allow-dirty + revert_version - name: upload PKGBUILD artifact if: inputs.upload_artifacts