-
Notifications
You must be signed in to change notification settings - Fork 8
148 lines (127 loc) Β· 5.12 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
name: Build, Test, Package and Push
# Controls when the action will run.
on:
# Triggers the workflow on pull request events and merges/pushes to main
push:
branches:
- '**'
paths-ignore:
- '**/*.md'
release:
types: [published]
schedule:
# Daily 5am australian/brisbane time
- cron: '0 19 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
id-token: write # This is required for requesting the JWT
jobs:
build:
runs-on: ubuntu-latest
# conditionally skip build on PR merge of release-please, because the release creation is going to trigger the real build
if: ${{ github.ref_name != 'main' || github.event.head_commit.author.username != 'team-integrations-fnm-bot' }}
outputs:
nuGetVersion: ${{ steps.git-version.outputs.nuGetVersion }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # all
- name: Cache the Maven packages to speed up build
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Install Atlas SDK
shell: bash
run: |
sudo sh -c 'echo "deb https://packages.atlassian.com/debian/atlassian-sdk-deb/ stable contrib" >> /etc/apt/sources.list'
wget https://packages.atlassian.com/api/gpg/key/public
sudo apt-key add public
sudo apt-get update
sudo apt-get install atlassian-plugin-sdk
atlas-version
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Call GitVersion
uses: gittools/actions/gitversion/[email protected]
- name: Determine Version
id: git-version
run: |
if [ "${{ github.event_name }}" == "schedule" ]
then
echo "::set-output name=nuGetVersion::${GITVERSION_MAJORMINORPATCH}-nightly-${{ github.run_number }}"
echo "Version: ${GITVERSION_MAJORMINORPATCH}-nightly-${{ github.run_number }}"
else
echo "::set-output name=nuGetVersion::${GITVERSION_FULLSEMVER}"
echo "Version: ${GITVERSION_FULLSEMVER}"
fi
- name: Build π
run: |
mvn versions:set -DnewVersion=${{ steps.git-version.outputs.nuGetVersion }}
- name: Unit Test π
run : |
atlas-unit-test
- name: Publish π
run: |
atlas-package
- uses: actions/upload-artifact@v4
with:
name: bamboo.${{ steps.git-version.outputs.nuGetVersion }}
path: '**/target/*.jar'
publish:
name: Publish the packages
needs: [build]
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
env:
OCTOPUS_CLI_SERVER: ${{ secrets.OCTOPUS_URL }}
OCTOPUS_HOST: ${{ secrets.OCTOPUS_URL }}
OCTOPUS_SPACE: Integrations
steps:
- uses: actions/download-artifact@v4
with:
name: bamboo.${{ needs.build.outputs.nuGetVersion }}
path: .
- name: Compress package for Octopus
run: |
mkdir artifacts
zip -j artifacts/bamboo.${{ needs.build.outputs.nuGetVersion }}.zip target/bamboo.jar
- name: Install Octopus CLI π
uses: OctopusDeploy/install-octopus-cli-action@v1
with:
version: latest
- name: Login to Octopus Deploy
uses: OctopusDeploy/login@v1
with:
server: https://deploy.octopus.app
service_account_id: 9447a9ba-6dbc-417e-bbed-835ec435d648
- name: Push build information π
uses: OctopusDeploy/push-build-information-action@v3
with:
debug: true
packages: bamboo
version: ${{ needs.build.outputs.nuGetVersion }}
- name: Push package to feed π
uses: OctopusDeploy/push-package-action@v3
with:
packages: 'artifacts/bamboo.${{ needs.build.outputs.nuGetVersion }}.zip'
- 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:
project: 'Bamboo Plugin'
package_version: ${{ needs.build.outputs.nuGetVersion }}
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 }}