Skip to content

Commit

Permalink
Merge pull request #928 from gisaia/ci/release
Browse files Browse the repository at this point in the history
ci: add release with github action
  • Loading branch information
QuCMGisaia authored Jan 6, 2025
2 parents f861bae + 307f555 commit 98226df
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 24 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release ARLAS-wui

on:
workflow_dispatch:
inputs:
version:
description: Version to release
required: true
stage:
type: choice
description: Stage of the release
required: true
options:
- beta
- rc
- stable
stage_iteration:
description: Iteration of the release (needed for beta and rc)
required: false
latest:
type: boolean
description: Latest release?
default: true

run-name: Release ARLAS-wui ${{inputs.version}} ${{inputs.stage}} ${{inputs.stage_iteration}}

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Release
env:
# secrets are defined here : https://github.com/organizations/gisaia/settings/secrets/actions
NPM_EMAIL: ${{ secrets.NPM_EMAIL }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
GITHUB_CHANGELOG_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bash release.sh -version=${{inputs.version}} -s=${{inputs.stage}} -i=${{inputs.stage_iteration}} -ref_branch=${{ steps.extract_branch.outputs.branch }} ${{inputs.latest && ' ' || '--not-latest'}}
48 changes: 24 additions & 24 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ set -e
SCRIPT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd)"
PROJECT_ROOT_DIRECTORY="$(dirname "$SCRIPT_DIRECTORY")"

# dockerlogin=`docker info | sed '/Username:/!d;s/.* //'`
# if [ -z "$dockerlogin" ] ; then echo "your are not logged on dockerhub"; exit -1; else echo "logged as "$dockerlogin ; fi

if [ -z "$GITHUB_CHANGELOG_TOKEN" ] ; then echo "Please set GITHUB_CHANGELOG_TOKEN environment variable"; exit -1; fi

function clean {
Expand All @@ -16,30 +13,27 @@ function clean {
trap clean EXIT

usage(){
echo "Usage: ./release.sh -rel=X [--no-tests]"
echo " -rel|--app-release release arlas-app X version"
echo " -dev|--app-dev development arlas-app version (-SNAPSHOT qualifier will be automatically added)"
echo " --no-tests Skip running integration tests"
echo " --not-latest Doesn't tag the release version as the latest."
echo " -s|--stage Stage of the release : beta | rc | stable. If --stage is 'rc' or 'beta', there is no merge of develop into master (if -ref_branch=develop)"
echo " -i|--stage_iteration=n, the released version will be : [x].[y].[z]-beta.[n] OR [x].[y].[z]-rc.[n] according to the given --stage"
echo " -ref_branch | --reference_branch from which branch to start the release."
echo "Usage: ./release.sh -version=X [--no-tests]"
echo " -version Release ARLAS-wui X version"
echo " --no-tests Skip running integration tests"
echo " --not-latest Doesn't tag the release version as the latest."
echo " -s|--stage Stage of the release : beta | rc | stable. If --stage is 'rc' or 'beta', there is no merge of develop into master (if -ref_branch=develop)"
echo " -i|--stage_iteration=n The released version will be : [x].[y].[z]-beta.[n] OR [x].[y].[z]-rc.[n] according to the given --stage"
echo " -ref_branch|--reference_branch From which branch to start the release."
echo " Add -ref_branch=develop for a new official release"
echo " Add -ref_branch=x.x.x for a maintenance release"
exit 1
}

STAGE="stable"
TESTS="YES"
IS_LATEST_VERSION="YES"

for i in "$@"
do
case $i in
-rel=*|--app-release=*)
APP_REL="${i#*=}"
shift # past argument=value
;;
-dev=*|--app-dev=*)
APP_DEV="${i#*=}"
-version=*)
VERSION="${i#*=}"
shift # past argument=value
;;
--no-tests)
Expand Down Expand Up @@ -68,9 +62,6 @@ case $i in
esac
done

VERSION="${APP_REL}"
DEV="${APP_DEV}"

if [ "$TESTS" == "YES" ]; then
ng lint
ng test
Expand Down Expand Up @@ -135,7 +126,7 @@ git pull origin "$REF_BRANCH"

if [ "${STAGE}" == "rc" ] || [ "${STAGE}" == "beta" ];
then
VERSION="${APP_REL}-${STAGE}.${STAGE_ITERATION}"
VERSION="${VERSION}-${STAGE}.${STAGE_ITERATION}"
fi

echo "==> Set version"
Expand Down Expand Up @@ -174,10 +165,12 @@ echo "==> Docker"
docker build -f docker/Dockerfile-production --no-cache --build-arg version=${VERSION} --tag gisaia/arlas-wui:${VERSION} .
docker build -f docker/Dockerfile-production-no-analytics --no-cache --build-arg version=${VERSION} --tag gisaia/arlas-wui:${VERSION}-no-analytics .

echo " -- Publishing docker images"
docker push gisaia/arlas-wui:${VERSION}
docker push gisaia/arlas-wui:${VERSION}-no-analytics
if [ "${STAGE}" == "stable" ] && [ "${IS_LATEST_VERSION}" == "YES" ];
then
echo " -- Publishing latest"
docker tag gisaia/arlas-wui:${VERSION} gisaia/arlas-wui:latest
docker push gisaia/arlas-wui:latest
fi
Expand All @@ -193,6 +186,7 @@ if [ "${STAGE}" == "rc" ] || [ "${STAGE}" == "beta" ];
echo " -- tagged as ${STAGE}"
npm publish --tag=${STAGE}
else
echo " -- Stable release"
npm publish
fi
cd ../..
Expand All @@ -214,10 +208,16 @@ if [ "${REF_BRANCH}" == "develop" ] && [ "${STAGE}" == "stable" ];
git rebase origin/master
fi

npm --no-git-tag-version version "${DEV}-dev"
npm --no-git-tag-version --prefix src version "${DEV}-dev"
IFS='.' read -ra TAB <<< "$VERSION"
major=${TAB[0]}
minor=${TAB[1]}
newminor=$(( $minor + 1 ))
newDevVersion=${major}.${newminor}.0

npm --no-git-tag-version version "${newDevVersion}-dev"
npm --no-git-tag-version --prefix src version "${newDevVersion}-dev"

git commit -a -m "development version ${DEV}-dev"
git commit -a -m "development version ${newDevVersion}-dev"
git push origin ${REF_BRANCH}

echo "==> Well done :)"

0 comments on commit 98226df

Please sign in to comment.