Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert to push tag trigger for release creation #218

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/create-release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create Release Tag

on:
workflow_dispatch:
inputs:
git_ref:
description: 'Git ref'
type: string
required: false
default: 'main'
semver:
description: 'Semantic Version (defaults to 0.0.0-commit)'
type: string
required: false
default: ''

jobs:
create-tag:
name: Create Tag
runs-on: windows-2022
timeout-minutes: 5
permissions:
contents:
write # Create tag and release

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.git_ref }}

- name: Create Tag
shell: pwsh
run: |
$SemVer = "${{ github.event.inputs.semver }}"
if ($SemVer -eq "") {
$ShortCommit = & git rev-parse --short=8 "${{ github.event.inputs.git_ref }}" | Out-String
$SemVer = "0.0.0-$ShortCommit"
}
if (-not $SemVer -match "^v\d+\.\d+\.\d+(-\w+)?$") {
throw "Unexpected SemVer format: $SemVer"
}

$Tag = "v$SemVer"
& git tag $Tag
& git push origin $Tag
58 changes: 16 additions & 42 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
name: Release & Publish

on:
workflow_dispatch:
inputs:
git_ref:
description: 'Git ref'
type: string
required: false
default: 'main'
semver:
description: 'Semantic Version (empty defaults to 0.0.0-commit)'
type: string
required: false
default: ''
publish_nuget:
description: 'Publish NuGet package'
type: boolean
required: false
default: false
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'

jobs:
build-and-publish:
Expand All @@ -26,30 +13,23 @@ jobs:
timeout-minutes: 15
permissions:
contents:
write # Create tag and release
write # Create release

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.git_ref }}
- uses: ./.github/actions/setup-swift

- name: Compute Version
id: context
id: version
shell: pwsh
run: |
$SemVer = "${{ github.event.inputs.semver }}"
if ($SemVer -eq "") {
$Commit = & git rev-parse --short=8 | Out-String
$SemVer = "0.0.0-$Commit"
}
if (-not $SemVer -match "^v\d+\.\d+\.\d+(-\w+)?$") {
throw "Unexpected SemVer format: $SemVer"
$TagName = "${{ github.ref_name }}"
if ($TagName.StartsWith("v")) { $SemVer = $TagName.Substring(1) }
else {
$CommitHash = "${{ github.sha }}".Substring(0, 7)
$SemVer = "0.0.0-$CommitHash"
}

Write-Output "::set-output name=tag::v$SemVer"
Write-Output "::set-output name=semver::$SemVer"

- uses: ./.github/actions/setup-swift
echo "::set-output name=semver::$SemVer"

- name: CMake Configure
working-directory: Generator
Expand All @@ -68,25 +48,19 @@ jobs:
$OutputPath = "${{ github.workspace }}\SwiftWinRT.nupkg"
& .\Create-NuGetPackage.ps1 `
-NativeExe "build\release\Sources\SwiftWinRT\SwiftWinRT.exe" `
-Version "${{ steps.context.outputs.semver }}" `
-Version "${{ steps.version.outputs.semver }}" `
-OutputPath $OutputPath
(Get-FileHash $OutputPath).Hash | Out-File -FilePath "$OutputPath.sha256"

- name: Create Git Tag
shell: pwsh
run: |
& git tag "${{ steps.context.outputs.tag }}"
& git push origin "${{ steps.context.outputs.tag }}"

- name: Create GitHub Release
if: github.event_name == 'push'
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create Release
$SemVer = "${{ steps.context.outputs.semver }}"
$TagName = "${{ steps.context.outputs.tag }}"
$TagName = "${{ github.ref_name }}"
$SemVer = "${{ steps.version.outputs.semver }}"
$RepositoryUrl = "${{ github.repository }}"
$ExtraArgs = @()
if ($SemVer.StartsWith("0.") -or $SemVer.Contains("-")) { $ExtraArgs += "--prerelease" }
Expand Down
Loading