Skip to content

Publish Release Artifacts (1.2.x) #14

Publish Release Artifacts (1.2.x)

Publish Release Artifacts (1.2.x) #14

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_DEV_CENTRAL_ACCESS_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 }}