forked from Cox-Automotive/apollo-client-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 28
77 lines (66 loc) · 2.07 KB
/
trigger.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
name: Trigger
on:
workflow_dispatch:
inputs:
branch:
description: "Branch to release from"
required: true
default: "main"
version:
description: "Release version"
required: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 8
- name: Cache Maven
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build
run: mvn --no-transfer-progress -B -U --file pom.xml install
tag:
name: Tag
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
# required for triggering release workflow on tagging
token: ${{ secrets.GIT_ACCESS_TOKEN }}
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 8
- name: Cache Maven
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Create tag
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
BRANCH=${{ github.event.inputs.branch }}
VERSION=${{ github.event.inputs.version }}
echo "Releasing $VERSION from $BRANCH branch"
git checkout $BRANCH
mvn --no-transfer-progress -B versions:set versions:commit -DnewVersion=$VERSION
git config --global user.email "22281426+aoudiamoncef@users.noreply.github.com"
git config --global user.name "Automated release"
git commit -a -m "build: releasing version $VERSION"
git tag v$VERSION
git push origin $BRANCH
git push origin v$VERSION