-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (95 loc) · 3.52 KB
/
adoscope-nuget-publish-promote-stable.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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 }}