forked from datalens-tech/datalens-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (66 loc) · 2.86 KB
/
publish_platform.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
name: Publish Platform
permissions:
contents: write
jobs:
build:
name: datalens-ui
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: .
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: 'Get last release'
run: |
COMMIT_NAME=$(git log -n 1 --pretty=format:%s)
LAST_RELEASE_VERSION=$(curl -L https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq -r '.|=sort_by(.name|ltrimstr("v")|split(".")|map(tonumber)|[.[0],.[1],-.[2]])|.[-1].name' | sed 's|v||')
echo "Last release version: ${LAST_RELEASE_VERSION}"
MAIN_COMMIT=$(git rev-parse origin/main)
echo "Main commit: ${MAIN_COMMIT}"
LAST_RELEASE_BRANCH="release-${LAST_RELEASE_VERSION}"
LAST_RELEASE_COMMIT=$(git rev-parse "origin/$LAST_RELEASE_BRANCH")
echo "Last release commit: ${LAST_RELEASE_COMMIT}"
if [ "$MAIN_COMMIT" = "$LAST_RELEASE_COMMIT" ]; then echo "Hash commit in main branch matches the last release branch commit" && exit 1; fi
echo "COMMIT_NAME=$COMMIT_NAME" >> "$GITHUB_ENV"
echo "LAST_RELEASE_VERSION=$LAST_RELEASE_VERSION" >> "$GITHUB_ENV"
- name: 'Make new release version number'
run: |
npm version "$LAST_RELEASE_VERSION" --no-git-tag-version --allow-same-version
TAG_NEW_VERSION=$(npm version minor --no-git-tag-version --allow-same-version)
NEW_VERSION=$(echo $TAG_NEW_VERSION | sed 's|v||')
echo "NEW_VERSION=$NEW_VERSION" >> "$GITHUB_ENV"
echo "TAG_NEW_VERSION=$TAG_NEW_VERSION" >> "$GITHUB_ENV"
- name: 'Create new release branch'
run: |
NEW_BRANCH="release-$NEW_VERSION"
git checkout -b "$NEW_BRANCH"
echo "Created new release branch: $NEW_BRANCH"
echo "NEW_BRANCH=$NEW_BRANCH" >> "$GITHUB_ENV"
- name: 'Commit package version'
run: |
git config user.email "" && git config user.name "GitHub Release"
git add package.json && git add package-lock.json && git commit -am "Bump version to $NEW_VERSION [release]"
git push --set-upstream origin "$NEW_BRANCH"
- uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NEW_VERSION }}
release_name: ${{ env.TAG_NEW_VERSION }}
commitish: ${{ env.NEW_BRANCH }}
body: ${{ env.COMMIT_NAME }}
draft: false
prerelease: false
- name: 'Success notify'
run: echo "Version bumped to '$TAG_NEW_VERSION' and pushed to remote repository"