Skip to content

Commit e297a74

Browse files
authored
fix: Updated build pipeline to trigger releases from GitHub
1 parent 1da0e44 commit e297a74

File tree

3 files changed

+67
-25
lines changed

3 files changed

+67
-25
lines changed

.github/workflows/build.yml

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
name: Build
22

33
on:
4+
workflow_call:
45
push:
56
branches: [ main ]
6-
tags: [ '*' ]
77
pull_request:
88
branches: [ main ]
99

10+
release:
11+
types: [created]
12+
13+
workflow_dispatch:
14+
inputs:
15+
release-tag:
16+
description: "The tag of the release being replicated in Octopus Deploy"
17+
required: true
18+
1019
env:
11-
OCTOPUS_VERSION: 5.0.${{ github.run_number }}
20+
PACKAGE_VERSION: 5.2.${{ github.run_number }}
21+
OCTOPUS_CLI_SERVER: ${{ secrets.OCTOPUS_URL }}
22+
OCTOPUS_CLI_API_KEY: ${{ secrets.INTEGRATIONS_API_KEY }}
1223

1324
jobs:
1425
build:
1526
name: Build code
1627
runs-on: ubuntu-latest
28+
outputs:
29+
package_version: ${{ steps.build.outputs.package_version }}
1730
steps:
1831
- uses: actions/checkout@v2
1932
- name: Use Node.js
@@ -22,13 +35,16 @@ jobs:
2235
node-version: '16'
2336
cache: 'npm'
2437
- name: Build
38+
id: build
2539
run: |
2640
npm install
27-
npm run build -- --extensionVersion $OCTOPUS_VERSION
41+
npm run build -- --extensionVersion $PACKAGE_VERSION
42+
echo "::set-output name=package_version::$PACKAGE_VERSION"
2843
- uses: actions/upload-artifact@v2
2944
with:
3045
name: dist
3146
path: dist/
47+
3248
test:
3349
name: Run test matrix
3450
needs: build
@@ -58,41 +74,69 @@ jobs:
5874
name: Tests report
5975
path: 'reports/jest-*.xml'
6076
reporter: jest-junit
77+
6178
package:
6279
name: Package and Push artifacts to Octopus
63-
needs: test
80+
needs: [build, test]
6481
runs-on: ubuntu-latest
6582
steps:
66-
- uses: actions/checkout@v2
83+
- uses: actions/checkout@v3
6784
- uses: actions/download-artifact@v2
6885
with:
6986
name: dist
7087
path: dist
88+
7189
- name: Use Node.js
7290
uses: actions/setup-node@v2
7391
with:
7492
node-version: '16'
7593
cache: 'npm'
76-
- name: Install Go
77-
uses: actions/setup-go@v2
78-
with:
79-
go-version: '^1.17.7'
94+
8095
- name: Embed octo portable
8196
run: |
8297
pwsh ./embed-octo.ps1
98+
8399
- name: Replace versions in tasks and create vsix
84100
run: |
85-
./pack.ps1 -environment Production -version $Env:OCTOPUS_VERSION -setupTaskDependencies
86-
./pack.ps1 -environment Test -version $Env:OCTOPUS_VERSION
101+
./pack.ps1 -environment Production -version ${{ needs.build.outputs.package_version }} -setupTaskDependencies
102+
./pack.ps1 -environment Test -version ${{ needs.build.outputs.package_version }}
87103
shell: pwsh
104+
88105
- name: Create Packages
106+
id: create-packages
89107
run: |
90-
tar -czf OctoTFS.vsix.$OCTOPUS_VERSION.tar.gz ./dist/Artifacts/**/*.vsix
91-
tar -czf OctoTFS.publish.$OCTOPUS_VERSION.tar.gz ./publish.ps1 ./dist/extension-manifest*.json
92-
- name: Push Package
93-
run: |
94-
docker run -e "OCTOPUS_CLI_SERVER=${{ secrets.OCTOPUS_URL }}" -e "OCTOPUS_CLI_API_KEY=${{ secrets.INTEGRATIONS_API_KEY }}" -v $(pwd):/src octopusdeploy/octo push --space "Integrations" --package OctoTFS.vsix.$OCTOPUS_VERSION.tar.gz --package OctoTFS.publish.$OCTOPUS_VERSION.tar.gz --overwrite-mode OverwriteExisting
95-
- name: Create Release
108+
tar -czf OctoTFS.vsix.${{ needs.build.outputs.package_version }}.tar.gz ./dist/Artifacts/**/*.vsix
109+
tar -czf OctoTFS.publish.${{ needs.build.outputs.package_version }}.tar.gz ./publish.ps1 ./dist/extension-manifest*.json
110+
111+
- name: Install Octopus CLI 🐙
112+
uses: OctopusDeploy/install-octopus-cli-action@v1.2.0
113+
with:
114+
version: '*'
115+
116+
- name: Push Package 🐙
117+
uses: OctopusDeploy/push-package-action@v1.1.2
118+
with:
119+
space: "Integrations"
120+
packages: |
121+
OctoTFS.vsix.${{ needs.build.outputs.package_version }}.tar.gz
122+
OctoTFS.publish.${{ needs.build.outputs.package_version }}.tar.gz
123+
124+
- name: Fetch Release Notes
125+
id: fetch-release-notes
126+
if: github.event_name == 'release'
96127
run: |
97-
docker run -e "OCTOPUS_CLI_SERVER=${{ secrets.OCTOPUS_URL }}" -e "OCTOPUS_CLI_API_KEY=${{ secrets.INTEGRATIONS_API_KEY }}" -v $(pwd):/src octopusdeploy/octo create-release --space "Integrations" --project "Azure DevOps Extension" --packageVersion $OCTOPUS_VERSION --releaseNumber $OCTOPUS_VERSION --gitRef "${{ (github.ref_type == 'tag' && 'main' ) || (github.head_ref || github.ref) }}" --gitCommit "${{ github.event.after || github.event.pull_request.head.sha }}"
128+
echo "::debug::${{github.event_name}}"
129+
OUTPUT_FILE="release_notes.txt"
130+
jq --raw-output '.release.body' ${{ github.event_path }} | sed 's#\r# #g' > $OUTPUT_FILE
131+
echo "::set-output name=release-note-file::$OUTPUT_FILE"
98132
133+
- name: Create a release in Octopus Deploy 🐙
134+
uses: OctopusDeploy/create-release-action@v1.1.1
135+
with:
136+
space: "Integrations"
137+
project: "Azure DevOps Extension"
138+
package_version: ${{ needs.build.outputs.package_version }}
139+
channel: ${{ (github.event_name == 'release' && 'Release') || '' }}
140+
release_notes_file: ${{ (github.event_name == 'release' && steps.fetch-release-notes.outputs.release-note-file) || ''}}
141+
git_ref: ${{ (github.ref_type == 'tag' && 'main' ) || (github.head_ref || github.ref) }}
142+
git_commit: ${{ github.event.after || github.event.pull_request.head.sha }}

.octopus/deployment_settings.ocl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ connectivity_policy {
33
}
44

55
versioning_strategy {
6-
template = "#{Octopus.Version.LastMajor}.#{Octopus.Version.LastMinor}.#{Octopus.Version.NextPatch}"
6+
7+
donor_package {
8+
package = "OctoTFS.vsix"
9+
step = "Push to Azure Marketplace"
10+
}
711
}

pack.ps1

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ function SetupTaskDependencies($workingDirectory) {
6060
mkdir "$tempPath/node_modules"
6161
& npm install --prefix $tempPath azure-pipelines-task-lib azure-pipelines-tool-lib
6262
& npm dedup --prefix $tempPath
63-
& go install github.com/tj/node-prune@latest
64-
65-
$goPath = go env GOPATH
66-
$command = "$goPath/bin/node-prune"
67-
68-
Invoke-Expression "$command $tempPath/node_modules"
6963

7064
$taskManifestFiles = Get-ChildItem $workingDirectory -Include "task.json" -Recurse
7165

0 commit comments

Comments
 (0)