adoscope-nuget-publish-promote-stable #44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: adoscope-nuget-publish-promote-stable | |
on: | |
workflow_dispatch: | |
inputs: | |
package_version: | |
description: 'NuGet package version to approve' | |
required: true | |
default: '1.0.0-commithash-alpha' | |
new_package_version: | |
description: 'Promotion version' | |
required: true | |
default: '1.0.0' | |
env: | |
NuGetDirectory: ${{ github.workspace }}/nuget | |
NuGetDirectoryWin: ${{ github.workspace }}\nuget | |
jobs: | |
extract-commit-hash: | |
name: Extract Commit Hash | |
runs-on: ubuntu-latest | |
outputs: | |
commit_hash: ${{ steps.set_commit_hash.outputs.commit_hash }} | |
steps: | |
- name: Extract Commit Hash | |
id: set_commit_hash | |
env: | |
PACKAGE_VERSION: ${{ github.event.inputs.package_version }} | |
run: | | |
$pattern = '-([0-9a-f]{7,40})-alpha' | |
if ($env:PACKAGE_VERSION -match $pattern) { | |
$commitHash = $Matches[1] | |
echo "commit_hash=$commitHash" >> $GITHUB_ENV | |
echo "commit_hash=$commitHash" >> $GITHUB_OUTPUT | |
} else { | |
Write-Error "Commit hash not found in package version." | |
exit 1 | |
} | |
shell: pwsh | |
build-package: | |
name: Build | |
uses: gentoorax/Promethix.Framework.Ado/.github/workflows/adoscope-reusable-build.yaml@main | |
needs: extract-commit-hash | |
with: | |
buildVersion: ${{ github.event.inputs.new_package_version }} | |
dotnetVersion: '8.0.x' | |
commitHash: ${{ needs.extract-commit-hash.outputs.commit_hash }} | |
secrets: | |
repoToken: ${{ secrets.REPO_ACCESS_TOKEN }} | |
tag-commit: | |
name: Tag Commit | |
needs: build-package | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # This is crucial to fetch all history for tagging | |
token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
- name: Tag Commit Hash | |
env: | |
NEW_PACKAGE_VERSION: ${{ github.event.inputs.new_package_version }} | |
MY_PAT: ${{ secrets.REPO_ACCESS_TOKEN }} | |
COMMIT_HASH: ${{ needs.extract-commit-hash.outputs.commit_hash }} | |
run: | | |
git config user.name 'github-actions' | |
git config user.email 'github-actions@github.com' | |
# Checkout the commit | |
git checkout $env:COMMIT_HASH | |
# Tag the commit | |
git tag $env:NEW_PACKAGE_VERSION | |
# Push the tag: | |
git push origin refs/tags/$env:NEW_PACKAGE_VERSION | |
# Push the tag using the PAT and correct repository URL | |
$repoUrl = "${{ github.server_url }}/${{ github.repository }}".TrimStart('https://') | |
git push "https://github-actions:${env:MY_PAT}@$repoUrl" refs/tags/$env:NEW_PACKAGE_VERSION | |
shell: pwsh | |
publish: | |
needs: tag-commit | |
name: Publish Promethix.Framework.Ado | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
id: download-artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: Promethix.Framework.Ado.NuGet.${{ github.event.inputs.new_package_version }} | |
path: ${{ env.NuGetDirectory }} | |
- name: Publish Nuget Package Promethix.Framework.Ado | |
working-directory: . | |
run: | | |
echo Directory List | |
ls | |
echo NuGet Directory List | |
ls ${{ env.NuGetDirectory }} | |
NEW_PACKAGE_VERSION=${{ github.event.inputs.new_package_version }} | |
dotnet nuget push ${{ env.NuGetDirectory }}/Promethix.Framework.Ado.${NEW_PACKAGE_VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} | |