-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (87 loc) · 3.8 KB
/
upgrade-version.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Upgrade Version and Deploy
on:
pull_request:
types:
- closed
branches:
- 'main'
jobs:
upgrade-version:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.merged == true }}
permissions:
contents: write
steps:
- name: Docker Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Check out the repo and login with bot account
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Java 21
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: '21.0.3'
cache: 'maven'
cache-dependency-path: 'server/pom.xml'
- name: Setup Git
env:
GIT_AUTHOR_NAME: GitHub Actions
GIT_AUTHOR_EMAIL: "[email protected]"
run: |
git config --global user.name "${{env.GIT_AUTHOR_NAME}}"
git config --global user.email "${{env.GIT_AUTHOR_EMAIL}}"
- name: Retrieve versions
id: versions
shell: bash
run: |
VERSIONS=$(scripts/retrieve-versions.sh server/pom.xml)
NEXT_VERSION=$(echo $VERSIONS | cut -d ':' -f 1)
NEW_SNAPSHOT=$(echo $VERSIONS | cut -d ':' -f 2)
echo "next_version=$(echo $VERSIONS | cut -d ':' -f 1)" >> $GITHUB_OUTPUT
echo "new_snapshot=$(echo $VERSIONS | cut -d ':' -f 2)" >> $GITHUB_OUTPUT
- name: Upgrade server pom version to ${{ steps.versions.outputs.next_version }}
shell: bash
run: |
mvn versions:set -DnewVersion=${{ steps.versions.outputs.next_version }} --file server/pom.xml
- name: Upgrade version in README.md
shell: bash
run: |
sed -i 's/https:\/\/img.shields.io\/badge\/Version-[0-9]\+\.[0-9]\+\.[0-9]-blue/https:\/\/img.shields.io\/badge\/Version-${{ steps.versions.outputs.next_version }}-blue/g' README.md
sed -i 's/image: heavynimbus\/heavy-mock-http-server:[0-9]\+\.[0-9]\+\.[0-9]/image: heavynimbus\/heavy-mock-http-server:${{ steps.versions.outputs.next_version }}/g' README.md
- name: Git Add changes
run: git add server/pom.xml README.md
- name: Git Commit changes
run: git commit -m "🚀⬆️ Upgrade version to ${{ steps.versions.outputs.next_version }}"
- name: Git Tag ${{ steps.versions.outputs.next_version }}
run: git tag ${{ steps.versions.outputs.next_version }} HEAD
- name: Git Push changes and tags
with:
token: ${{ secrets.GITHUB_TOKEN }}
run: git push --force origin HEAD:${{ github.ref_name }} --tags
- name: Build Docker image ${{ steps.versions.outputs.next_version }}
env:
NEXT_VERSION: ${{ steps.versions.outputs.next_version }}
run: |
docker build -t heavy-mock-http-server:$NEXT_VERSION server
- name: Push Docker image ${{ steps.versions.outputs.next_version }}
env:
NEXT_VERSION: ${{ steps.versions.outputs.next_version }}
run: |
docker tag "heavy-mock-http-server:$NEXT_VERSION" "heavynimbus/heavy-mock-http-server:$NEXT_VERSION"
docker push "heavynimbus/heavy-mock-http-server:$NEXT_VERSION"
- name: Set snapshot version
run: |
mvn versions:set -DnewVersion=${{ steps.versions.outputs.new_snapshot }} --file server/pom.xml
- name: Git Add changes
run: git add server/pom.xml
- name: Git Commit changes
run: git commit -m "⬆️ Upgrade version to ${{ steps.versions.outputs.new_snapshot }}"
- name: Git Push changes
with:
token: ${{ secrets.GITHUB_TOKEN }}
run: git push --force origin HEAD:${{ github.ref_name }}