Skip to content

Publish Release Artifacts #104

Publish Release Artifacts

Publish Release Artifacts #104

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"
- 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: Checkout Docker repo
uses: actions/checkout@v3
with:
repository: ballerina-platform/module-ballerina-docker
path: module-ballerina-docker
- name: Copy zip artifact
run: cp ballerina/build/distributions/ballerina-22*.zip module-ballerina-docker/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: module-ballerina-docker/base/docker/
push: true
tags: ballerina/ballerina:$GIT_TAG
platforms: linux/amd64,linux/arm64
build-args: |
BALLERINA_DIST=ballerina-$VERSION.zip
- name: Build and push dev container image
id: docker_build_devcontainer
uses: docker/build-push-action@v6
with:
context: module-ballerina-docker/base/devcontainer/
push: true
tags: ballerina/ballerina-devcontainer:$GIT_TAG
build-args: |
BALLERINA_DIST=ballerina-$LONG_VERSION-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 }}