forked from jenkinsci/jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
223 lines (194 loc) · 6.81 KB
/
publish-release-artifact.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
211
212
213
214
215
216
217
218
219
220
221
222
223
name: Publish artifact
on:
release:
types: [published]
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
determine-version:
runs-on: ubuntu-latest
outputs:
project-version: ${{ steps.set-version.outputs.project-version }}
is-lts: ${{ steps.set-version.outputs.is-lts }}
is-rc: ${{ steps.set-version.outputs.is-rc }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17
cache: "maven"
- name: Set version
id: set-version
run: |
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
dot_count=$(echo $version | sed 's/[^.]//g' | awk '{ print length }')
if [ "${dot_count}" = '2' ]
then
is_lts=true
else
is_lts=false
fi
is_rc=false
if [[ ${version} == *"-SNAPSHOT" ]]; then
is_rc=true
fi
echo "Version is $version, is_lts: $is_lts, is_rc: $is_rc"
echo "is-lts=${is_lts}" >> $GITHUB_OUTPUT
echo "project-version=$version" >> $GITHUB_OUTPUT
echo "is-rc=${is_rc}" >> $GITHUB_OUTPUT
war:
permissions:
contents: write # to upload release asset (softprops/action-gh-release)
runs-on: ubuntu-latest
needs: determine-version
if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
steps:
- name: Fetch war
id: fetch-war
run: |
FILE_NAME=jenkins.war
PROJECT_VERSION=${{ needs.determine-version.outputs.project-version }}
IS_LTS=${{ needs.determine-version.outputs.is-lts }}
echo $PROJECT_VERSION
echo "file-name=$FILE_NAME" >> $GITHUB_OUTPUT
REPO=war
if [ ${IS_LTS} = 'true' ]
then
REPO=war-stable
fi
echo $REPO
wget -q https://get.jenkins.io/${REPO}/${PROJECT_VERSION}/${FILE_NAME}
- name: Upload Release Asset
id: upload-war
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ steps.fetch-war.outputs.file-name }}
debian:
permissions:
contents: write # to upload release asset (softprops/action-gh-release)
runs-on: ubuntu-latest
needs: determine-version
if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
steps:
- name: Fetch Deb
id: fetch-deb
if: always()
run: |
PROJECT_VERSION=${{ needs.determine-version.outputs.project-version }}
echo $PROJECT_VERSION
FILE_NAME=jenkins_${PROJECT_VERSION}_all.deb
IS_LTS=${{ needs.determine-version.outputs.is-lts }}
echo "file-name=$FILE_NAME" >> $GITHUB_OUTPUT
REPO=debian
if [ ${IS_LTS} = 'true' ]
then
REPO=debian-stable
fi
echo $REPO
wget -q https://get.jenkins.io/${REPO}/${FILE_NAME}
- name: Upload Release Asset
id: upload-deb
if: always()
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ steps.fetch-deb.outputs.file-name }}
redhat:
permissions:
contents: write # to upload release asset (softprops/action-gh-release)
runs-on: ubuntu-latest
needs: determine-version
if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
steps:
- name: Fetch RPM
id: fetch-rpm
if: always()
run: |
PROJECT_VERSION=${{ needs.determine-version.outputs.project-version }}
echo $PROJECT_VERSION
FILE_NAME=jenkins-${PROJECT_VERSION}-1.1.noarch.rpm
IS_LTS=${{ needs.determine-version.outputs.is-lts }}
echo "file-name=$FILE_NAME" >> $GITHUB_OUTPUT
REPO=redhat
if [ ${IS_LTS} = 'true' ]
then
REPO=redhat-stable
fi
echo $REPO
wget -q https://get.jenkins.io/${REPO}/${FILE_NAME}
- name: Upload Release Asset
id: upload-rpm
if: always()
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ steps.fetch-rpm.outputs.file-name }}
windows:
permissions:
contents: write # to upload release asset (softprops/action-gh-release)
runs-on: ubuntu-latest
needs: determine-version
if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
steps:
- name: Fetch MSI
id: fetch-msi
if: always()
run: |
PROJECT_VERSION=${{ needs.determine-version.outputs.project-version }}
echo $PROJECT_VERSION
FILE_NAME=jenkins.msi
IS_LTS=${{ needs.determine-version.outputs.is-lts }}
echo "file-name=$FILE_NAME" >> $GITHUB_OUTPUT
REPO=windows
if [ ${IS_LTS} = 'true' ]
then
REPO=windows-stable
fi
echo $REPO
wget -q https://get.jenkins.io/${REPO}/${PROJECT_VERSION}/${FILE_NAME}
- name: Upload Release Asset
id: upload-msi
if: always()
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ steps.fetch-msi.outputs.file-name }}
suse:
permissions:
contents: write # to upload release asset (softprops/action-gh-release)
runs-on: ubuntu-latest
needs: determine-version
if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
steps:
- name: Fetch suse rpm
id: fetch-suse-rpm
if: always()
run: |
PROJECT_VERSION=${{ needs.determine-version.outputs.project-version }}
echo $PROJECT_VERSION
# we need opensuse to the file
OUTPUT_FILE_NAME=jenkins-${PROJECT_VERSION}-1.2-opensuse.noarch.rpm
IS_LTS=${{ needs.determine-version.outputs.is-lts }}
echo "file-name=$OUTPUT_FILE_NAME" >> $GITHUB_OUTPUT
REPO=opensuse
if [ ${IS_LTS} = 'true' ]
then
REPO=opensuse-stable
fi
echo $REPO
wget -q https://get.jenkins.io/${REPO}/jenkins-${PROJECT_VERSION}-1.2.noarch.rpm -O ${OUTPUT_FILE_NAME}
- name: Upload Release Asset
id: upload-suse-rpm
if: always()
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ steps.fetch-suse-rpm.outputs.file-name }}