Add test python release

This commit is contained in:
Caelan Sayler
2025-06-15 15:09:01 +01:00
committed by Caelan
parent eb0cbb2df1
commit ffd5818496

View File

@@ -26,201 +26,230 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
path: ./ path: ./
- name: Download vpk
uses: actions/download-artifact@v4
with:
name: packages
run-id: ${{ github.event.inputs.workflow_run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: ./packages
- name: Download lib-nodejs
uses: actions/download-artifact@v4
with:
name: lib-nodejs
run-id: ${{ github.event.inputs.workflow_run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: ./lib-nodejs
- name: Download lib-rust
uses: actions/download-artifact@v4
with:
name: lib-rust
run-id: ${{ github.event.inputs.workflow_run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: ./lib-rust
- name: Download lib-c
uses: actions/download-artifact@v4
with:
name: lib-c
run-id: ${{ github.event.inputs.workflow_run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: ./lib-c-files
- name: Load version from file - name: Load version from file
run: | run: |
version=$(cat version.txt | xargs) version=$(cat version.txt | xargs)
echo "PKG_VERSION=$version" >> $GITHUB_ENV echo "PKG_VERSION=$version" >> $GITHUB_ENV
- name: Create lib-c zip package # - name: Download vpk
working-directory: ./lib-c-files # uses: actions/download-artifact@v4
run: | # with:
mkdir -p ../lib-c # name: packages
zip -r ../lib-c/velopack_libc_$PKG_VERSION.zip . # run-id: ${{ github.event.inputs.workflow_run_id }}
# github-token: ${{ secrets.GITHUB_TOKEN }}
# path: ./packages
- uses: actions/checkout@v4 # - name: Download lib-nodejs
# uses: actions/download-artifact@v4
# with:
# name: lib-nodejs
# run-id: ${{ github.event.inputs.workflow_run_id }}
# github-token: ${{ secrets.GITHUB_TOKEN }}
# path: ./lib-nodejs
# - name: Download lib-rust
# uses: actions/download-artifact@v4
# with:
# name: lib-rust
# run-id: ${{ github.event.inputs.workflow_run_id }}
# github-token: ${{ secrets.GITHUB_TOKEN }}
# path: ./lib-rust
# - name: Download lib-c
# uses: actions/download-artifact@v4
# with:
# name: lib-c
# run-id: ${{ github.event.inputs.workflow_run_id }}
# github-token: ${{ secrets.GITHUB_TOKEN }}
# path: ./lib-c-files
# - name: Create lib-c zip package
# working-directory: ./lib-c-files
# run: |
# mkdir -p ../lib-c
# zip -r ../lib-c/velopack_libc_$PKG_VERSION.zip .
- name: Download lib-python
uses: actions/download-artifact@v4
with: with:
path: ./repo name: lib-python
fetch-depth: 0 run-id: ${{ github.event.inputs.workflow_run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: ./lib-python-files
- name: Checkout release commit - name: Create lib-python zip package
working-directory: ./repo working-directory: ./lib-python-files
run: | run: |
echo $PKG_VERSION mkdir -p ../lib-python
COMMIT_HASH=$(gh run view ${{ github.event.inputs.workflow_run_id }} --json headSha -q ".headSha") zip -r ../lib-python/velopack_libpython_$PKG_VERSION.zip .
git checkout $COMMIT_HASH
- name: Generate Release - name: test-artifact
working-directory: ./repo uses: actions/upload-artifact@v4
shell: pwsh with:
run: | name: test-artifact
$ErrorActionPreference = "Stop" path: lib-python/*
retention-days: 1
$currentTag = Get-Content -Path "../version.txt" -Raw # - uses: actions/checkout@v4
$currentTag = $currentTag.Trim() # with:
# path: ./repo
# fetch-depth: 0
# Get the previous release tag # - name: Checkout release commit
Write-Host "Detecting previous release tag..." # working-directory: ./repo
$gitTags = git tag --list # run: |
# echo $PKG_VERSION
# COMMIT_HASH=$(gh run view ${{ github.event.inputs.workflow_run_id }} --json headSha -q ".headSha")
# git checkout $COMMIT_HASH
$tags = $gitTags | ForEach-Object { # - name: Generate Release
$fullTag = $_ # working-directory: ./repo
$isPrerelease = $fullTag -like "*-*" # shell: pwsh
# run: |
# $ErrorActionPreference = "Stop"
if ($isPrerelease) { # $currentTag = Get-Content -Path "../version.txt" -Raw
# For prerelease versions, extract the version part before the hyphen # $currentTag = $currentTag.Trim()
$versionPart = $fullTag.Split('-')[0]
} else {
$versionPart = $fullTag
}
try { # # Get the previous release tag
$version = [System.Version]$versionPart # Write-Host "Detecting previous release tag..."
[PSCustomObject]@{ # $gitTags = git tag --list
FullTag = $fullTag
Version = $version
IsPrerelease = $isPrerelease
}
} catch {
# Skip tags that cannot be parsed into a System.Version
$null
}
} | Where-Object { $_ -ne $null }
$isCurrentPrerelease = $currentTag -like "*-*" # $tags = $gitTags | ForEach-Object {
$latestPrerelease = ($tags | Where-Object { $_.IsPrerelease } | Sort-Object Version -Descending | Select-Object -First 1).FullTag # $fullTag = $_
$latestStable = ($tags | Where-Object { -not $_.IsPrerelease } | Sort-Object Version -Descending | Select-Object -First 1).FullTag # $isPrerelease = $fullTag -like "*-*"
$latestOverall = ($tags | Sort-Object Version -Descending | Select-Object -First 1).FullTag
if ($isCurrentPrerelease) { # if ($isPrerelease) {
$releaseArg = "--prerelease" # # For prerelease versions, extract the version part before the hyphen
$previousTag = $latestOverall # $versionPart = $fullTag.Split('-')[0]
} else { # } else {
$releaseArg = "--latest" # $versionPart = $fullTag
$previousTag = $latestStable # }
}
Write-Host "Current version is prerelease: $isCurrentPrerelease" # try {
Write-Host "Latest prerelease: $latestPrerelease" # $version = [System.Version]$versionPart
Write-Host "Latest stable: $latestStable" # [PSCustomObject]@{
Write-Host "Latest overall: $latestOverall" # FullTag = $fullTag
Write-Host "---" # Version = $version
Write-Host "Current tag: $currentTag" # IsPrerelease = $isPrerelease
Write-Host "Previous tag: $previousTag" # }
# } catch {
# # Skip tags that cannot be parsed into a System.Version
# $null
# }
# } | Where-Object { $_ -ne $null }
# Push the tag to the repository # $isCurrentPrerelease = $currentTag -like "*-*"
Write-Host "Tagging release commit..." # $latestPrerelease = ($tags | Where-Object { $_.IsPrerelease } | Sort-Object Version -Descending | Select-Object -First 1).FullTag
git tag $currentTag # $latestStable = ($tags | Where-Object { -not $_.IsPrerelease } | Sort-Object Version -Descending | Select-Object -First 1).FullTag
git push origin $currentTag # $latestOverall = ($tags | Sort-Object Version -Descending | Select-Object -First 1).FullTag
# Generate release notes # if ($isCurrentPrerelease) {
Write-Host "Generating release notes..." # $releaseArg = "--prerelease"
$headers = @{ # $previousTag = $latestOverall
"Authorization" = "Bearer ${{ github.token }}" # } else {
"Accept" = "application/vnd.github.v3+json" # $releaseArg = "--latest"
} # $previousTag = $latestStable
$body = @{ # }
"tag_name" = "$currentTag"
"previous_tag_name" = "$previousTag"
} | ConvertTo-Json
$apiUrl = "https://api.github.com/repos/velopack/velopack/releases/generate-notes"
$response = Invoke-RestMethod -Uri $apiUrl -Method Post -Headers $headers -Body $body -ContentType 'application/json'
$releaseName = $response.name # Write-Host "Current version is prerelease: $isCurrentPrerelease"
$releaseBody = $response.body # Write-Host "Latest prerelease: $latestPrerelease"
# Write-Host "Latest stable: $latestStable"
# Write-Host "Latest overall: $latestOverall"
# Write-Host "---"
# Write-Host "Current tag: $currentTag"
# Write-Host "Previous tag: $previousTag"
# Move dependencies to dedicated section # # Push the tag to the repository
$lines = $releaseBody -split "`n" # Write-Host "Tagging release commit..."
$dependenciesLines = @() # git tag $currentTag
$otherLines = @() # git push origin $currentTag
$changelog = ""
foreach ($line in $lines) { # # Generate release notes
if ($line -match 'Full Changelog') { # Write-Host "Generating release notes..."
$changelog = $line # $headers = @{
} elseif ($line -match '@renovate') { # "Authorization" = "Bearer ${{ github.token }}"
$dependenciesLines += $line # "Accept" = "application/vnd.github.v3+json"
} else { # }
$otherLines += $line # $body = @{
} # "tag_name" = "$currentTag"
} # "previous_tag_name" = "$previousTag"
# } | ConvertTo-Json
# $apiUrl = "https://api.github.com/repos/velopack/velopack/releases/generate-notes"
# $response = Invoke-RestMethod -Uri $apiUrl -Method Post -Headers $headers -Body $body -ContentType 'application/json'
$releaseBody = $otherLines -join "`n" # $releaseName = $response.name
if ($dependenciesLines.Count -gt 0) { # $releaseBody = $response.body
$releaseBody += "`## Dependency Updates`n"
$releaseBody += "`n<details>`n"
$releaseBody += "`n<summary>Expand to see all changed dependencies</summary>`n`n"
$releaseBody += $dependenciesLines -join "`n"
$releaseBody += "`n`n</details>`n"
}
$releaseBody += "`n" + $changelog
Write-Host "Release name: $releaseName" # # Move dependencies to dedicated section
Write-Host "Release body:" # $lines = $releaseBody -split "`n"
Write-Host $releaseBody # $dependenciesLines = @()
# $otherLines = @()
# $changelog = ""
# Create release # foreach ($line in $lines) {
Write-Host "Creating release..." # if ($line -match 'Full Changelog') {
$notesFilePath = "./RELEASE_NOTES.md" # $changelog = $line
$releaseBody | Out-File -FilePath $notesFilePath -Encoding utf8 # } elseif ($line -match '@renovate') {
gh release create $currentTag --title $releaseName --notes-file $notesFilePath $releaseArg --verify-tag # $dependenciesLines += $line
# } else {
# $otherLines += $line
# }
# }
# Upload artifacts # $releaseBody = $otherLines -join "`n"
Write-Host "Uploading artifacts..." # if ($dependenciesLines.Count -gt 0) {
gh release upload $currentTag (get-item ../packages/*.nupkg) # $releaseBody += "`## Dependency Updates`n"
gh release upload $currentTag (get-item ../lib-nodejs/*.tgz) # $releaseBody += "`n<details>`n"
gh release upload $currentTag (get-item ../lib-rust/*.crate) # $releaseBody += "`n<summary>Expand to see all changed dependencies</summary>`n`n"
gh release upload $currentTag (get-item ../lib-c/*.zip) # $releaseBody += $dependenciesLines -join "`n"
# $releaseBody += "`n`n</details>`n"
# }
# $releaseBody += "`n" + $changelog
- name: Publish NuGet Packages # Write-Host "Release name: $releaseName"
run: | # Write-Host "Release body:"
for f in packages/*.nupkg; do # Write-Host $releaseBody
dotnet nuget push "$f" -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
done
- name: Publish NPM Package # # Create release
working-directory: ./lib-nodejs # Write-Host "Creating release..."
run: | # $notesFilePath = "./RELEASE_NOTES.md"
npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" # $releaseBody | Out-File -FilePath $notesFilePath -Encoding utf8
npm publish velopack-$PKG_VERSION.tgz --access public # gh release create $currentTag --title $releaseName --notes-file $notesFilePath $releaseArg --verify-tag
- name: Publish Rust Crate # # Upload artifacts
working-directory: ./lib-rust # Write-Host "Uploading artifacts..."
run: | # gh release upload $currentTag (get-item ../packages/*.nupkg)
tar -xzf velopack-$PKG_VERSION.crate # gh release upload $currentTag (get-item ../lib-nodejs/*.tgz)
cd velopack-$PKG_VERSION # gh release upload $currentTag (get-item ../lib-rust/*.crate)
rm Cargo.toml.orig # gh release upload $currentTag (get-item ../lib-c/*.zip)
rm .cargo_vcs_info.json
cargo login ${{ secrets.CARGO_TOKEN }} # - name: Publish NuGet Packages
cargo publish --allow-dirty --no-verify # run: |
# for f in packages/*.nupkg; do
# dotnet nuget push "$f" -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
# done
# - name: Publish NPM Package
# working-directory: ./lib-nodejs
# run: |
# npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
# npm publish velopack-$PKG_VERSION.tgz --access public
# - name: Publish Rust Crate
# working-directory: ./lib-rust
# run: |
# tar -xzf velopack-$PKG_VERSION.crate
# cd velopack-$PKG_VERSION
# rm Cargo.toml.orig
# rm .cargo_vcs_info.json
# cargo login ${{ secrets.CARGO_TOKEN }}
# cargo publish --allow-dirty --no-verify
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
packages-dir: lib-python-files/
verbose: true