-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (75 loc) · 2.82 KB
/
release_server.yml
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
name: Deploy to Fly
on:
push:
branches: [main]
paths:
- "server/**"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: 🎙 Discord notification 1/3
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "Mave-metrics release started ⏳"
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: Import GPG key
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Git configuration
run: |
git config --global user.email "${{ steps.import-gpg.outputs.email }}"
git config --global user.name "${{ steps.import-gpg.outputs.name }}"
- name: 🔑 Install Fly cli
uses: superfly/flyctl-actions/setup-flyctl@master
- name: 🚀 Build & deploy to Fly
run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
working-directory: server
- name: Fetch all tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Determine new version tag
id: versioning
run: |
LATEST_TAG=$(git tag -l "server-v*" --sort=-v:refname | head -n 1)
echo "LATEST_TAG: $LATEST_TAG"
if [[ "$LATEST_TAG" == "" ]]; then
NEW_TAG="server-v0.1.0"
else
VERSION_NUM=$(echo "$LATEST_TAG" | sed 's/server-v//')
echo "VERSION_NUM: $VERSION_NUM"
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION_NUM"
echo "Before increment PATCH value is: $PATCH"
PATCH=$((PATCH + 1))
echo "MAJOR: $MAJOR - MINOR: $MINOR - PATCH: $PATCH"
NEW_TAG="server-v${MAJOR}.${MINOR}.${PATCH}"
fi
echo "New tag: $NEW_TAG"
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
- name: 🎙 Discord notification 2/3
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "Mave-metrics ${{ steps.release.outputs.new_tag }} has been deployed 🚀"
- name: 🎙 Discord notification 3/3
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
- name: Create and push new tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag ${{ env.NEW_TAG }}
GIT_USER_NAME=$(git config --get user.name)
echo "Using GitHub user: $GIT_USER_NAME"
git push https://$GIT_USER_NAME:${{ secrets.GITHUB_TOKEN }}@github.com/maveio/metrics.git --tags