Repository navigation
97 lines (84 loc) · 3.37 KB
/
Copy pathcommon-release.yml
File metadata and controls
97 lines (84 loc) · 3.37 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Common Release Workflow
on:
workflow_call:
inputs:
tag:
required: false
type: string
jobs:
build-sdk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT_ACTIONS }}
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: "https://registry.npmjs.org"
- name: Install Packages
run: npm install --ignore-scripts
- name: Build
run: npm run build
- name: Get Previous Tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@v1
with:
fallback: 1.0.0
- name: Resolve Branch Name
id: resolve-branch
if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }}
run: |
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }})
BRANCH_NAME=$(git branch -r --contains $TAG_COMMIT | grep -o 'origin/.*' | sed 's|origin/||' | head -n 1)
if [ -z "$BRANCH_NAME" ]; then
echo "Error: Could not resolve branch for the tag."
exit 1
fi
echo "Resolved Branch Name: $BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
- name: Bump Version
run: |
chmod +x ./scripts/bump_version.sh
if ${{ inputs.tag == 'internal' }}; then
./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "$(git rev-parse --short "$GITHUB_SHA")"
else
./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}"
fi
- name: Commit Changes
run: |
git config user.name ${{ github.actor }}
git config user.email ${{ github.actor }}@users.noreply.github.com
if [[ "${{ inputs.tag }}" == "beta" || "${{ inputs.tag }}" == "public" ]]; then
git checkout ${{ env.branch_name }}
fi
git add package.json
if [[ "${{ inputs.tag }}" == "beta" || "${{ inputs.tag }}" == "public" ]]; then
git commit -m "[AUTOMATED] Release - ${{ steps.previoustag.outputs.tag }}"
git push origin ${{ env.branch_name }}
elif [[ "${{ inputs.tag }}" == "internal" ]]; then
git commit -m "[AUTOMATED] Private Release ${{ steps.previoustag.outputs.tag }}-dev.$(git rev-parse --short $GITHUB_SHA)"
git push origin ${{ github.ref_name }} -f
fi
- name: Publish
run: |
if [[ "${{ inputs.tag }}" == "beta" ]]; then
npm publish --tag beta
elif [[ "${{ inputs.tag }}" == "public" ]]; then
MAJOR_VERSION=$(node -p "require('./package.json').version.split('.')[0]")
if [[ "$MAJOR_VERSION" == "1" ]]; then
npm publish --tag v1
else
npm publish
fi
elif [[ "${{ inputs.tag }}" == "internal" ]]; then
JFROG_AUTH=$(echo -n "$JFROG_USERNAME:$JFROG_PASSWORD" | base64 -w 0)
npm config set registry https://prekarilabs.jfrog.io/prekarilabs/api/npm/npm/
npm config set //prekarilabs.jfrog.io/prekarilabs/api/npm/npm/:_auth "$JFROG_AUTH"
npm publish
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
JFROG_USERNAME: ${{ secrets.JFROG_USERNAME }}
JFROG_PASSWORD: ${{ secrets.JFROG_PASSWORD }}