-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 2.19 KB
/
cd.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
name: Deployment
on:
workflow_dispatch:
push:
branches:
- "main"
paths:
- ".github/workflows/**"
- "jest.config.js"
- "package.json"
- "src/**"
- "tests/**"
- "tsconfig.json"
- "yarn.lock"
permissions:
issues: write
contents: write
pull-requests: write
repository-projects: write
jobs:
continuous-deployment:
name: Deployment
runs-on: ubuntu-latest
steps:
- name: 👇 Checkout
uses: actions/checkout@v3
- name: 🤹 Instal Deps
run: yarn install
- name: 🧪 Test
run: yarn test
- name: 🧱 Build
run: |
yarn build
if [ "$(git status --porcelain)" != "" ]; then
echo "GIT_IS_DIRTY=true" >> $GITHUB_ENV
else
echo "GIT_IS_DIRTY=false" >> $GITHUB_ENV
fi
- name: ✊ Bump Version
if: env.GIT_IS_DIRTY == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
CURRENT_BRANCH=${GITHUB_REF}
case $CURRENT_BRANCH in "refs/heads/"*)
CURRENT_BRANCH=$(echo "$CURRENT_BRANCH" | sed "s@refs/heads/@@")
esac
echo "machine github.com" > "$HOME/.netrc"
echo " login $GITHUB_ACTOR" >> "$HOME/.netrc"
echo " password ${{ github.token }}" >> "$HOME/.netrc"
echo "machine api.github.com" >> "$HOME/.netrc"
echo " login $GITHUB_ACTOR" >> "$HOME/.netrc"
echo " password ${{ github.token }}" >> "$HOME/.netrc"
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
LATEST_TAG=$(gh api repos/endaft/$(basename $PWD)/releases/latest --jq=.tag_name)
IFS=. read -r v1 v2 v3 <<< "${LATEST_TAG}" # split into (integer) components
v3=$((v3 + 1)) # do the math
LATEST_TAG="${v1}.${v2}.${v3}"
git commit -a -m "chore: updates dist js"
git tag -f "$LATEST_TAG" -m "Version $LATEST_TAG"
git tag -f latest -m "The latest version"
git push origin "$CURRENT_BRANCH:$CURRENT_BRANCH" --follow-tags --force --tags