-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathazure-pipelines-release.yml
More file actions
186 lines (174 loc) · 6.89 KB
/
azure-pipelines-release.yml
File metadata and controls
186 lines (174 loc) · 6.89 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
##############################################################
# Description:
# This Pipeline is used to build and release the application
# the artifacts are stored in GitHub Releases based on Tags
# with the pattern v*.*.* (e.g. V24.01.17)
#
# Also the documentation is generated and updated to the
# github-pages branch with the name `github-pages` for the url
# https://mbc-engineering.github.io/log4TC/
##############################################################
# Build Trigger when new tag created that starts with v
trigger:
tags:
include:
- v*
# Disable PR Trigger
pr: none
# Define repositories that can be used
resources:
repositories:
- repository: gh-pages-repo
type: github
endpoint: github.com_bqstony
name: mbc-engineering/log4TC
ref: gh-pages
# self is the trigger repo + branch
stages:
# ╔════════════════════════╗
# ║ Build Stage ║
# ╚════════════════════════╝
- stage: 'build'
displayName: 'Build the applications'
jobs:
# log4TC
- template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/log4tc/build-job.yaml
# Documentation
- template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/docs/build-job.yaml
# tclibrary
- template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/tclibrary/build-job.yaml
# ╔════════════════════════╗
# ║ PublishRelease ║
# ╚════════════════════════╝
- stage: 'PublishRelease'
displayName: 'Publish to github Tag'
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
pool:
vmImage: 'windows-latest'
environment: publish-github
strategy:
runOnce:
deploy:
steps:
- checkout: none
- download: current
artifact: msi
- download: current
artifact: tclibrary
- download: current
artifact: log4TC-linux-x64
- download: current
artifact: log4TC-linux-arm64
# For easy testing comment out the above and uncomment the below
# - task: DownloadBuildArtifacts@1
# inputs:
# buildType: 'specific'
# project: '5542496b-1239-4d74-a233-9da3b0388d39'
# pipeline: '20'
# specificBuildWithTriggering: true
# buildVersionToDownload: 'latest'
# downloadType: 'specific'
# downloadPath: '$(Pipeline.Workspace)/msi'
# cleanDestinationFolder: true
- powershell: Get-ChildItem -Force -Path $(Pipeline.Workspace)/msi
displayName: 'list artifact files'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Pipeline.Workspace)/log4TC-linux-x64'
archiveType: 'tar'
tarCompression: 'gz'
archiveFile: '$(Build.ArtifactStagingDirectory)/log4TC-linux-x64.tgz'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Pipeline.Workspace)/log4TC-linux-arm64'
archiveType: 'tar'
tarCompression: 'gz'
archiveFile: '$(Build.ArtifactStagingDirectory)/log4TC-linux-arm64.tgz'
- task: GitHubRelease@1
displayName: 'Create GitHub Releases'
inputs:
gitHubConnection: 'github.com_bqstony'
repositoryName: 'mbc-engineering/log4TC'
action: 'create'
target: '$(Build.SourceVersion)'
# Pattern check does not work for me
#tagSource: 'gitTag'
#tagPattern: 'v*'
tagSource: 'userSpecifiedTag'
tag: '$(Build.SourceBranchName)' # The PR, Branch or Tag Name
releaseNotesSource: 'inline'
assets: |
$(Pipeline.Workspace)/msi/**
$(Pipeline.Workspace)/tclibrary/**
$(Build.ArtifactStagingDirectory)/**
changeLogCompareToRelease: 'lastFullRelease'
changeLogType: 'commitBased'
- stage: 'PublishGitHubPages'
displayName: 'Publish to github pages'
dependsOn: PublishRelease
condition: succeeded()
jobs:
- deployment: Deploy
pool:
vmImage: 'windows-latest'
environment: publish-github-pages
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: docs
# For easy testing comment out the above and uncomment the below
# - task: DownloadBuildArtifacts@1
# inputs:
# buildType: 'specific'
# project: '5542496b-1239-4d74-a233-9da3b0388d39'
# pipeline: '20'
# specificBuildWithTriggering: true
# buildVersionToDownload: 'latest'
# downloadType: 'specific'
# downloadPath: '$(Pipeline.Workspace)/docs'
# cleanDestinationFolder: true
- powershell: Get-ChildItem -Force -Path $(Pipeline.Workspace)/docs
displayName: 'list artifact files in workspace=$(Pipeline.Workspace)'
- checkout: gh-pages-repo
submodules: recursive
persistCredentials: true
- script: |
git config user.email "AutomatedDeploy@bot.com"
git config user.name "AutomatedDeploy"
git fetch
git status
git branch -a
git remote -v
git checkout gh-pages
displayName: 'prepare git repo'
workingDirectory: '$(Build.SourcesDirectory)'
- task: PowerShell@2
displayName: 'Clear old files in gh-pages branch'
inputs:
targetType: 'inline'
script: |
# Get all files and subdirectories except the .git directory
$itemsToDelete = Get-ChildItem | Where-Object { $_.Name -ne ".git" }
# Delete files and subdirectories
foreach ($item in $itemsToDelete) {
Remove-Item -Path $item.FullName -Recurse -Force
}
workingDirectory: '$(Build.SourcesDirectory)'
- powershell: Get-ChildItem -Force -Path $(Build.SourcesDirectory)
displayName: 'list gh-pages repo files in sourceDir=$(Build.SourcesDirectory)'
- script: |
xcopy "$(Pipeline.Workspace)/docs" "$(Build.SourcesDirectory)" /E /Y
displayName: 'Copy docs to gh-pages branch'
workingDirectory: '$(Build.SourcesDirectory)'
- script: |
git add .
git status
git commit -m "Update documentation from Release-$(Build.SourceBranchName)"
git push
displayName: 'Push changes to origin gh-pages branch'
workingDirectory: '$(Build.SourcesDirectory)'