-
Notifications
You must be signed in to change notification settings - Fork 0
210 lines (202 loc) · 6.89 KB
/
release.yml
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: Release
on:
workflow_dispatch:
inputs:
release_level:
type: choice
description: Release level
options:
- patch
- minor
- major
- prerelease
required: true
env:
PHASE_VERSION: v0.3.0
PHASE_REPO: i3drobotics/phase
jobs:
versioning:
runs-on: ubuntu-20.04
steps:
# Get latest released version
- uses: oprypin/find-latest-tag@v1
with:
repository: i3drobotics/phase-csharp # The repository to scan.
releases-only: true # All relevant tags have a GitHub release for them.
id: latest-tag # The step ID to refer to later.
# Generate new release version
- name: Generate new version
uses: actions-ecosystem/action-bump-semver@v1
id: bump-version
with:
current_version: ${{ steps.latest-tag.outputs.tag }}
level: ${{ github.event.inputs.release_level }}
# Add generated version to VERSION file
# remove 'v' character from version string
- name: Add to Version file
shell: bash
run: |
PROJ_VERSION=${{ steps.bump-version.outputs.new_version }}
PROJ_VERSION=${PROJ_VERSION:1}
echo "$PROJ_VERSION" > version.txt
# Upload version file for use in other jobs
- name: Archive version file
uses: actions/upload-artifact@v2
with:
name: version-file-${{ github.sha }}-phase-csharp-release
path: version.txt
# Build / test
build:
needs: [versioning]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2019]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v2
with:
dotnet-version: '5.0.408'
# Get project version
- name: Download version file artifact
uses: actions/download-artifact@v2
with:
name: version-file-${{ github.sha }}-phase-csharp-release
path: versioning
- name: Get project version
shell: bash
run: |
PROJ_VER=$(cat versioning/version.txt)
echo "$PROJ_VER" > version.txt
echo "PROJ_VER=$PROJ_VER" >> $GITHUB_ENV
# Install Phase
- name: Download Phase
uses: robinraju/[email protected]
with:
repository: ${{ env.PHASE_REPO }}
tag: ${{ env.PHASE_VERSION }}
fileName: phase-${{ env.PHASE_VERSION }}-windows-x86_64.zip
- name: Install Phase
shell: powershell
run: |
Expand-Archive -Path phase-${{ env.PHASE_VERSION }}-windows-x86_64.zip -DestinationPath "C:\Program Files\I3DR\Phase"
Get-ChildItem -Path "C:\Program Files\I3DR\Phase"
echo "C:\Program Files\I3DR\Phase\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# Build
- name: Build
shell: bash
run: |
dotnet build --configuration Release //p:Version=${PROJ_VER}
env:
Phase_DIR: "C:\\Program Files\\I3DR\\Phase"
# Unit Test
- name: Unit Test
shell: bash
run: |
dotnet test test/unit/phasecsharp-unit-test.csproj
dotnet test test/perf/phasecsharp-perf-test.csproj
env:
Phase_DIR: "C:\\Program Files\\I3DR\\Phase"
# Upload deployment artifact
# (for data sharing across jobs)
- name: Upload deployment artifact
uses: actions/upload-artifact@v3
with:
name: deployment-windows-2019-${{ github.sha }}-phase-csharp-release
path: deployment/bin
deploy:
needs: [build]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
# Get project version
- name: Download version file artifact
uses: actions/download-artifact@v2
with:
name: version-file-${{ github.sha }}-phase-csharp-release
path: versioning
- name: Get project version
shell: bash
run: |
PROJ_VER=$(cat versioning/version.txt)
echo "$PROJ_VER" > version.txt
echo "PROJ_VER=$PROJ_VER" >> $GITHUB_ENV
# Generate docs
- name: Install Doxygen
shell: bash
run: |
sudo apt update
sudo apt install -y doxygen
- name: Generate docs
shell: bash
run: |
./docs/gen_docs.sh
# Zip docs
- uses: papeloto/action-zip@v1
with:
files: deployment/docs/
dest: docs.zip
# Download deployments from build artifacts
- name: Download deployment artifact
uses: actions/download-artifact@v2
with:
name: deployment-windows-2019-${{ github.sha }}-phase-csharp-release
path: deployment/bin
# Zip binaries
- uses: papeloto/action-zip@v1
with:
files: deployment/bin/
dest: phase-csharp-v${{ env.PROJ_VER }}-windows-x86_64.zip
# Create release
- name: GitHub release
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: ${{ github.event.inputs.release_level == 'prerelease' }}
body_path: release.md
tag_name: v${{ env.PROJ_VER }}
files: |
phase-csharp-v${{ env.PROJ_VER }}-windows-x86_64.zip
docs.zip
# Update public docs
- name: Deploy public docs
if: ${{ github.event.inputs.release_level != 'prerelease' }}
uses: JamesIves/[email protected]
with:
branch: docs # The branch the action should deploy to.
folder: deployment/docs # The folder the action should deploy.
repository-name: i3drobotics/phase-csharp
# Get git variables
- name: Get commit variables
id: commit-vars
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
# Get release branch name
# 'preprod' for pre-release
# 'prod' for production release
- name: Get release branch
id: release-branch
shell: bash
run: |
export RELEASE_BRANCH="prod"
[[ ${{ github.event.inputs.release_level == 'prerelease' }} ]] && export RELEASE_BRANCH="preprod"
echo "::set-output name=branch_name::${RELEASE_BRANCH}"
# Merge branch into production
- name: Merge main -> prod
uses: devmasx/merge-branch@master
with:
type: now
target_branch: ${{ steps.release-branch.outputs.branch_name }}
github_token: ${{ github.token }}
message: merged ${{ steps.commit-vars.outputs.sha_short }}
cleanup:
needs: [deploy]
runs-on: ubuntu-20.04
steps:
- uses: geekyeggo/delete-artifact@v1
with:
name: |
version-file-${{ github.sha }}-phase-csharp-release
deployment-windows-2019-${{ github.sha }}-phase-csharp-release