-
Notifications
You must be signed in to change notification settings - Fork 192
169 lines (149 loc) · 7.26 KB
/
publish-release-artifacts.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
name: Publish Release Artifacts
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release Version e.g., 2201.1.1, 2201.1.1-rc1'
default: '2201.1.1'
required: true
jobs:
publish-artifacts:
name: Publish Release Artifacts
runs-on: ubuntu-latest
if: github.repository_owner == 'ballerina-platform'
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21.0.3'
- name: Set version env variable
id: set-version
run: |
RELEASE_VERSION=${{ github.event.inputs.release_version }}
VERSION=$(cut -d- -f1 <<< $RELEASE_VERSION)
CODE_NAME="swan-lake"
TAGGED_VERSION=$RELEASE_VERSION
LONG_VERSION=$VERSION-$CODE_NAME
UPDATE_NUMBER=$(cut -d'.' -f2 <<< $VERSION)
DISPLAY_VERSION="$VERSION (Swan Lake Update $UPDATE_NUMBER)"
echo VERSION=$VERSION >> $GITHUB_ENV
echo LONG_VERSION=$LONG_VERSION >> $GITHUB_ENV
echo DISPLAY_VERSION=$DISPLAY_VERSION >> $GITHUB_ENV
echo GIT_TAG=$TAGGED_VERSION >> $GITHUB_ENV
echo "::set-output name=version::$VERSION"
echo "::set-output name=taggedVersion::$TAGGED_VERSION"
echo "::set-output name=updateNumber::$UPDATE_NUMBER"
echo "::set-output name=longVersion::$LONG_VERSION"
- name: Download artifacts
run: |
baseUrl="https://github.com/ballerina-platform/ballerina-distribution/releases/download/v$GIT_TAG"
updateNumber=${{ steps.set-version.outputs.updateNumber }}
rm -rf $VERSION
mkdir $VERSION
cd $VERSION
wget "$baseUrl/ballerina-$LONG_VERSION.zip"
wget "$baseUrl/ballerina-$VERSION.zip"
wget "$baseUrl/ballerina-$LONG_VERSION-windows-x64.msi"
wget "$baseUrl/ballerina-$LONG_VERSION-linux-x64.deb"
wget "$baseUrl/ballerina-$LONG_VERSION-linux-x64.rpm"
wget "$baseUrl/ballerina-$LONG_VERSION-macos-x64.pkg"
if [ "$updateNumber" -ge 5 ]; then
wget "$baseUrl/ballerina-$LONG_VERSION-macos-arm-x64.pkg"
fi
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
devCentralToken: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }}
githubAccessToken: ${{ secrets.GITHUB_TOKEN }}
ballerinaBotWorkflow: $ {{ secrets.BALLERINA_BOT_WORKFLOW }}
- name: Generate metadata json
working-directory: ${{ steps.set-version.outputs.version }}
run: |
updateNumber=${{ steps.set-version.outputs.updateNumber }}
date=`date +%Y-%m-%d`
winInstSize=`ls -lh ballerina-$LONG_VERSION-windows-x64.msi | cut -d " " -f5 | sed 's/M/mb/g'`
linuxInstSize=`ls -lh ballerina-$LONG_VERSION-linux-x64.deb | cut -d " " -f5 | sed 's/M/mb/g'`
rpmInstSize=`ls -lh ballerina-$LONG_VERSION-linux-x64.rpm | cut -d " " -f5 | sed 's/M/mb/g'`
macInstSize=`ls -lh ballerina-$LONG_VERSION-macos-x64.pkg | cut -d " " -f5 | sed 's/M/mb/g'`
fileName=metadata.json
echo "{" >> $fileName
echo " \"version\":\"$VERSION\"," >> $fileName
echo " \"short-version\":\"$VERSION\"," >> $fileName
echo " \"display-version\":\"$DISPLAY_VERSION\"," >> $fileName
echo " \"release-date\":\"$date\"," >> $fileName
echo " \"windows-installer\":\"ballerina-$LONG_VERSION-windows-x64.msi\"," >> $fileName
echo " \"windows-installer-size\":\"$winInstSize\"," >> $fileName
echo " \"linux-installer\":\"ballerina-$LONG_VERSION-linux-x64.deb\"," >> $fileName
echo " \"linux-installer-size\":\"$linuxInstSize\"," >> $fileName
echo " \"macos-installer\":\"ballerina-$LONG_VERSION-macos-x64.pkg\"," >> $fileName
echo " \"macos-installer-size\":\"$macInstSize\"," >> $fileName
if [ "$updateNumber" -ge 5 ]; then
macArmInstSize=`ls -lh ballerina-$LONG_VERSION-macos-arm-x64.pkg | cut -d " " -f5 | sed 's/M/mb/g'`
echo " \"macos-arm-installer\":\"ballerina-$LONG_VERSION-macos-arm-x64.pkg\"," >> $fileName
echo " \"macos-arm-installer-size\":\"$macArmInstSize\"," >> $fileName
fi
echo " \"rpm-installer\":\"ballerina-$LONG_VERSION-linux-x64.rpm\"," >> $fileName
echo " \"rpm-installer-size\":\"$rpmInstSize\"," >> $fileName
echo " \"other-artefacts\":[ " >> $fileName
echo " \"ballerina-$LONG_VERSION.zip\"" >> $fileName
echo " ]", >> $fileName
echo " \"api-docs\":\"ballerina-api-docs-$VERSION.zip\"," >> $fileName
echo " \"release-notes\":\"ballerina-release-notes-$VERSION.md\"" >> $fileName
echo "}" >> $fileName
- name: Archive metadata json
uses: actions/upload-artifact@v4
with:
name: Metadata JSON
path: ${{ steps.set-version.outputs.version }}/metadata.json
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Clone Docker Repo
id: process-docker
run: |
git clone --single-branch --branch master https://github.com/ballerina-platform/module-ballerina-docker
DOCKER_REPO='module-ballerina-docker'
echo "::set-output name=dockerRepo::$DOCKER_REPO"
- name: Copy zip artifact
run: |
DOCKER_REPO=${{ steps.process-docker.outputs.dockerRepo }}
cp $VERSION/ballerina-$VERSION.zip $DOCKER_REPO/base/docker/
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push the Ballerina Docker image
id: docker_build
uses: docker/build-push-action@v6
with:
context: ${{ steps.process-docker.outputs.dockerRepo }}/base/docker/
push: true
tags: ballerina/ballerina:${{ steps.set-version.outputs.taggedVersion }}
platforms: linux/amd64,linux/arm64
build-args: |
BALLERINA_DIST=ballerina-${{ steps.set-version.outputs.version }}.zip
- name: Build and push dev container image
id: docker_build_devcontainer
uses: docker/build-push-action@v6
with:
context: ${{ steps.process-docker.outputs.dockerRepo }}/base/devcontainer/
push: true
tags: ballerina/ballerina-devcontainer:${{ steps.set-version.outputs.taggedVersion }}
build-args: |
BALLERINA_DIST=ballerina-${{ steps.set-version.outputs.longVersion }}-linux-x64.deb
- name: Publish Artifacts
run: |
sudo apt-get install python3-setuptools
python3 -m pip install --user awscli
aws configure set aws_access_key_id $s3_acc_id
aws configure set aws_secret_access_key $s3_acc_key
aws s3 cp $VERSION s3://dist-dev.ballerina.io/downloads/$VERSION --recursive
env:
s3_acc_id: ${{ secrets.S3_ID }}
s3_acc_key: ${{ secrets.S3_KEY }}