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