generated from microsoft/AL-Go-PTE
-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (141 loc) · 5.25 KB
/
CreateRelease.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Create release
on:
workflow_dispatch:
inputs:
appVersion:
description: App version to promote to release (default is latest)
required: false
default: 'latest'
name:
description: Name of this release
required: true
default: ''
tag:
description: Tag of this release
required: true
default: ''
draft:
description: Draft (Y/N)
required: false
default: 'N'
prerelease:
description: Prerelease (Y/N)
required: false
default: 'N'
concurrency: release
defaults:
run:
shell: PowerShell
jobs:
Initialization:
runs-on: [ windows-latest ]
outputs:
telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Initialize the workflow
id: init
uses: microsoft/AL-Go-Actions/[email protected]
with:
eventId: "DO0094"
CreateRelease:
runs-on: [ windows-latest ]
needs: [ Initialization ]
outputs:
artifacts: ${{ steps.analyzeartifacts.outputs.artifacts }}
upload_url: ${{ steps.createrelease.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Read settings
uses: microsoft/AL-Go-Actions/[email protected]
with:
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }}
get: TemplateUrl
- name: Check for updates to AL-Go system files
uses: microsoft/AL-Go-Actions/[email protected]
with:
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }}
templateUrl: ${{ env.TemplateUrl }}
- name: Analyze Artifacts
id: analyzeartifacts
run: |
Write-Host "Analyzing artifacts"
$appVersion = '${{ github.event.inputs.appVersion }}'
$headers = @{
"Authorization" = "token ${{ github.token }}"
"Accept" = "application/json"
}
$allArtifacts = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/actions/artifacts" | ConvertFrom-Json
$artifactsVersion = $appVersion
if ($appVersion -eq "latest") {
$artifact = $allArtifacts.artifacts | Where-Object { $_.name -like "*Apps-*" } | Select-Object -First 1
$artifactsVersion = $artifact.name.SubString($artifact.name.IndexOf('Apps-')+5)
}
$include = @()
$allArtifacts.artifacts | Where-Object { $_.name -like "*Apps-$($artifactsVersion)" } | ForEach-Object {
$include += $( [ordered]@{ "name" = $_.name; "url" = $_.archive_download_url } )
}
if ($include.Count -eq 0) {
Write-Host "::Error::No artifacts found"
exit 1
}
$artifacts = @{ "include" = $include }
$artifactsJson = $artifacts | ConvertTo-Json -compress
Write-Host "::set-output name=artifacts::$artifactsJson"
Write-Host "set-output name=artifacts::$artifactsJson"
- name: Prepare release notes
id: createreleasenotes
uses: microsoft/AL-Go-Actions/[email protected]
with:
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }}
tag_name: '${{github.event.inputs.tag}}'
- name: Create release
uses: actions/create-release@v1
id: createrelease
env:
GITHUB_TOKEN: ${{ github.token }}
with:
draft: ${{ github.event.inputs.draft=='Y' }}
prerelease: ${{ github.event.inputs.prerelease=='Y' }}
release_name: '${{ github.event.inputs.name }}'
tag_name: '${{ github.event.inputs.tag }}'
body: ${{ steps.createreleasenotes.outputs.releaseNotes }}
UploadArtifacts:
runs-on: [ windows-latest ]
needs: [ CreateRelease ]
strategy:
matrix: ${{ fromJson(needs.CreateRelease.outputs.artifacts) }}
fail-fast: true
steps:
- name: Download artifact
run: |
Write-Host "Downloading artifact ${{ matrix.name}}"
$headers = @{
"Authorization" = "token ${{ github.token }}"
"Accept" = "application/vnd.github.v3+json"
}
Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri '${{ matrix.url }}' -OutFile '${{ matrix.name }}.zip'
- name: Upload release artifacts
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ needs.createrelease.outputs.upload_url }}
asset_path: '${{ matrix.name }}.zip'
asset_name: '${{ matrix.name }}.zip'
asset_content_type: application/zip
PostProcess:
if: always()
runs-on: [ windows-latest ]
needs: [ Initialization, CreateRelease, UploadArtifacts ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Finalize the workflow
id: PostProcess
uses: microsoft/AL-Go-Actions/[email protected]
with:
eventId: "DO0094"
telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }}