-
Notifications
You must be signed in to change notification settings - Fork 192
135 lines (119 loc) · 5.78 KB
/
publish-release-artifacts-1.2.x.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
name: Publish Release Artifacts (1.2.x)
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release Version e.g., 1.2.31, 1.2.31-rc1'
default: '1.2.31'
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 8
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
- name: Set version env variable
id: set-version
run: |
RELEASE_VERSION=${{ github.event.inputs.release_version }}
VERSION=$(cut -d- -f1 <<< $RELEASE_VERSION)
TAGGED_VERSION=$RELEASE_VERSION
DISPLAY_VERSION=$VERSION
echo VERSION=$VERSION >> $GITHUB_ENV
echo DISPLAY_VERSION=$DISPLAY_VERSION >> $GITHUB_ENV
echo GIT_TAG=$TAGGED_VERSION >> $GITHUB_ENV
echo "::set-output name=version::$RELEASE_VERSION"
echo "::set-output name=taggedVersion::$TAGGED_VERSION"
- name: Download artifacts
run: |
baseUrl="https://github.com/ballerina-platform/ballerina-distribution/releases/download/v$GIT_TAG"
rm -rf $VERSION
mkdir $VERSION
cd $VERSION
wget "$baseUrl/ballerina-$VERSION.zip"
wget "$baseUrl/jballerina-$VERSION.zip"
wget "$baseUrl/ballerina-windows-installer-x64-$VERSION.msi"
wget "$baseUrl/ballerina-linux-installer-x64-$VERSION.deb"
wget "$baseUrl/ballerina-linux-installer-x64-$VERSION.rpm"
wget "$baseUrl/ballerina-macos-installer-x64-$VERSION.pkg"
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: |
date=`date +%Y-%m-%d`
winInstSize=`ls -lh ballerina-windows-installer-x64-$VERSION.msi | cut -d " " -f5 | sed 's/M/mb/g'`
linuxInstSize=`ls -lh ballerina-linux-installer-x64-$VERSION.deb | cut -d " " -f5 | sed 's/M/mb/g'`
rpmInstSize=`ls -lh ballerina-linux-installer-x64-$VERSION.rpm | cut -d " " -f5 | sed 's/M/mb/g'`
macInstSize=`ls -lh ballerina-macos-installer-x64-$VERSION.pkg | cut -d " " -f5 | sed 's/M/mb/g'`
fileName=metadata.json
echo { > $fileName
echo " \"version\":\"$VERSION\"," >> $fileName
echo " \"release-date\":\"$date\"," >> $fileName
echo " \"windows-installer\":\"ballerina-windows-installer-x64-$VERSION.msi\"," >> $fileName
echo " \"windows-installer-size\":\"$winInstSize\"," >> $fileName
echo " \"linux-installer\":\"ballerina-linux-installer-x64-$VERSION.deb\"," >> $fileName
echo " \"linux-installer-size\":\"$linuxInstSize\"," >> $fileName
echo " \"macos-installer\":\"ballerina-macos-installer-x64-$VERSION.pkg\"," >> $fileName
echo " \"macos-installer-size\":\"$macInstSize\"," >> $fileName
echo " \"rpm-installer\":\"ballerina-linux-installer-x64-$VERSION.rpm\"," >> $fileName
echo " \"rpm-installer-size\":\"$rpmInstSize\"," >> $fileName
echo " \"other-artefacts\":[ " >> $fileName
echo " \"ballerina-$VERSION.zip\"," >> $fileName
echo " \"ballerina-$VERSION.vsix\"" >> $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@v2
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: Process docker
id: process-docker
run: |
git clone --single-branch --branch ballerina-1.2.x https://github.com/ballerina-platform/module-ballerina-docker
DOCKER_REPO='module-ballerina-docker'
echo "::set-output name=dockerRepo::$DOCKER_REPO"
- name: Enable experimental functions
run: |
echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json
sudo service docker restart
docker version
- name: Build and push docker image
run: |
DOCKER_REPO=${{ steps.process-docker.outputs.dockerRepo }}
cp $VERSION/ballerina-$VERSION.zip $DOCKER_REPO/base/docker/
docker build --no-cache=true --squash --build-arg BALLERINA_DIST=ballerina-$VERSION.zip -t ballerina/ballerina:$VERSION $DOCKER_REPO/base/docker/
rm $DOCKER_REPO/base/docker/ballerina-$VERSION.zip
docker push ballerina/ballerina:$VERSION
docker rmi ballerina/ballerina:$VERSION
docker image prune -f
- 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 }}