forked from Eonasdan/tempus-dominus
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (53 loc) · 1.79 KB
/
feature-branch.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
name: Feature Branch Publish Package
on:
push:
branches:
- 'feature/*'
- 'bug/*'
- development
paths:
- src/js
jobs:
main:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: ./.github/workflows/base
- name: Set package version
id: set_version
run: |
# Get the branch name
BRANCH_NAME=${GITHUB_REF#refs/heads/}
# remove "feature/" prefix
BRANCH_NAME=${BRANCH_NAME#feature/}
# replace underscore with dashes (thanks semver)
BRANCH_NAME=${BRANCH_NAME//_/-}
BUILD_ID=$(echo $GITHUB_RUN_ID | cut -c1-7)
VERSION=$(node -p "const pkg = require('./package.json'); pkg.version")
NEW_VERSION="$VERSION-$BRANCH_NAME.$BUILD_ID"
#sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/g" ./package.json
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Build
uses: ./.github/workflows/build
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Create Release
run: npm run release:version ${{steps.set_version.outputs.VERSION }} ${{steps.set_version.outputs.NEW_VERSION }}
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${{steps.set_version.outputs.NEW_VERSION }}`,
sha: context.sha
})