Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup git flow #60

Merged
merged 3 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish
on:
pull_request:
types: [closed]
branches:
- develop
- beta
- stable
- 'v*.*.*'
push:
tags:
- 'custom-release-*'

env:
NODE_VERSION: 20

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install NODE JS
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'

- name: Install project
run: yarn install

- name: Calculate version
run: |
export BRANCH=${GITHUB_REF##*/}
export VERSION=$(bash ./scripts/calculate_version.sh)
echo "Version $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
( test $BRANCH = "stable" && export PRERELEASE=false ) || export PRERELEASE=true
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV

- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
prerelease: ${{ env.PRERELEASE }}
6 changes: 1 addition & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and test
name: Test

on:
push:
Expand Down Expand Up @@ -27,10 +27,6 @@ jobs:
with:
submodules: true

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Install NODE JS
uses: actions/setup-node@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
1.0.0
40 changes: 40 additions & 0 deletions scripts/calculate_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

set -e

VERSION=$(cat VERSION)
USAGE_MSG='Usage: BRANCH=[BRANCH] calculate_version.sh'

if [ -z "$BRANCH" ]
then
(>&2 echo 'You should provide branch')
echo "$USAGE_MSG"
exit 1
fi


if [ -z "$VERSION" ]; then
echo "The base version is not set."
exit 1
fi

LABEL="develop"
for known in "beta" "stable"
do
if [ "$BRANCH" = "$known" ]
then
LABEL="$BRANCH"
fi
done

git fetch --tags > /dev/null

for (( NUMBER=0; ; NUMBER++ ))
do
FULL_VERSION="$VERSION-$LABEL.$NUMBER"
TAG="$FULL_VERSION"
if ! [[ $(git tag -l | grep "$TAG") ]]; then
echo "$FULL_VERSION" | tr / -
break
fi
done
Loading