Publish Release Artifacts #94
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17.0.7' | |
- 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: Process docker | |
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: 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:$GIT_TAG $DOCKER_REPO/base/docker/ | |
rm $DOCKER_REPO/base/docker/ballerina-$VERSION.zip | |
docker push ballerina/ballerina:$GIT_TAG | |
docker rmi ballerina/ballerina:$GIT_TAG | |
docker image prune -f | |
- name: Build and push dev container | |
run: | | |
DOCKER_REPO=${{ steps.process-docker.outputs.dockerRepo }} | |
cp $VERSION/ballerina-$LONG_VERSION-linux-x64.deb $DOCKER_REPO/base/devcontainer/ | |
docker build --no-cache=true --squash --build-arg BALLERINA_DIST=ballerina-$LONG_VERSION-linux-x64.deb -t ballerina/ballerina-devcontainer:$GIT_TAG $DOCKER_REPO/base/devcontainer | |
rm $DOCKER_REPO/base/devcontainer/ballerina-$LONG_VERSION-linux-x64.deb | |
docker push ballerina/ballerina-devcontainer:$GIT_TAG | |
docker rmi ballerina/ballerina-devcontainer:$GIT_TAG | |
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 }} |