-
Notifications
You must be signed in to change notification settings - Fork 42
149 lines (131 loc) · 4.4 KB
/
build.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
name: Build
on:
workflow_call:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
# Daily 5am australian/brisbane time (7pm UTC)
- cron: "0 19 * * *"
release:
types: [created]
workflow_dispatch:
inputs:
release-tag:
description: "The tag of the release being replicated in Octopus Deploy"
required: true
env:
PACKAGE_VERSION: 6.0.${{ github.run_number }}
OCTOPUS_URL: ${{ secrets.OCTOPUS_URL }}
OCTOPUS_API_KEY: ${{ secrets.INTEGRATIONS_API_KEY }}
jobs:
build:
name: Build code
runs-on: ubuntu-latest
outputs:
package_version: ${{ steps.build.outputs.package_version }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
cache: "npm"
- name: Build
id: build
run: |
npm ci
npm run build -- --extensionVersion $PACKAGE_VERSION
echo "::set-output name=package_version::$PACKAGE_VERSION"
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
test:
name: Run test matrix
needs: build
runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: read
checks: write
strategy:
matrix:
os: [windows-2022, ubuntu-20.04, macos-12]
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
cache: "npm"
- name: Test
run: |
npm ci
npm run test
- uses: dorny/test-reporter@v1
if: success() || failure()
name: Tests report
with:
name: Tests report
path: "reports/jest-*.xml"
reporter: jest-junit
package:
name: Package and Push artifacts to Octopus
needs: [build, test]
runs-on: ubuntu-latest
if: github.event_name == 'release' || (github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]')
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
cache: "npm"
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: "^1.19.5"
- name: Embed octo portable
run: |
pwsh ./embed-octo.ps1
- name: Replace versions in tasks and create vsix
run: |
./pack.ps1 -environment Production -version ${{ needs.build.outputs.package_version }} -setupTaskDependencies
./pack.ps1 -environment Test -version ${{ needs.build.outputs.package_version }}
shell: pwsh
- name: Create Packages
id: create-packages
run: |
tar -czf OctoTFS.vsix.${{ needs.build.outputs.package_version }}.tar.gz ./Artifacts/**/*.vsix
tar -czf OctoTFS.publish.${{ needs.build.outputs.package_version }}.tar.gz ./publish.ps1 ./dist/extension-manifest*.json
- name: Push Package 🐙
uses: OctopusDeploy/push-package-action@v3
with:
space: "Integrations"
packages: |
OctoTFS.vsix.${{ needs.build.outputs.package_version }}.tar.gz
OctoTFS.publish.${{ needs.build.outputs.package_version }}.tar.gz
- name: Fetch Release Notes
id: fetch-release-notes
if: github.event_name == 'release'
run: |
echo "::debug::${{github.event_name}}"
OUTPUT_FILE="release_notes.txt"
jq --raw-output '.release.body' ${{ github.event_path }} | sed 's#\r# #g' > $OUTPUT_FILE
echo "::set-output name=release-note-file::$OUTPUT_FILE"
- name: Create a release in Octopus Deploy 🐙
uses: OctopusDeploy/create-release-action@v3
with:
space: "Integrations"
project: "Azure DevOps Extension"
package_version: ${{ needs.build.outputs.package_version }}
channel: ${{ (github.event_name == 'release' && 'Release') || '' }}
release_notes_file: ${{ (github.event_name == 'release' && steps.fetch-release-notes.outputs.release-note-file) || ''}}
git_ref: ${{ (github.ref_type == 'tag' && 'main' ) || (github.head_ref || github.ref) }}
git_commit: ${{ github.event.after || github.event.pull_request.head.sha }}