-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (67 loc) · 2.58 KB
/
development.yaml
File metadata and controls
75 lines (67 loc) · 2.58 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
name: Deploy Dev to GitHub Packages
on:
workflow_dispatch:
jobs:
deploy-dev:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Latest Tag
id: get-latest-tag
run: |
# Procura por tags que sigam o padrão vX.Y.Z
latest_tag=$(git tag -l 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1)
if [ -z "$latest_tag" ]; then
latest_tag="v0.0.0"
fi
echo "Latest tag: $latest_tag"
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
- name: Set Dev Version with Inverted Timestamp
id: set-dev-version
run: |
# Remove o "v" do início da tag
version_without_v="${LATEST_TAG#v}"
# Gera o timestamp invertido com o formato AAAAMMDD_HHSSmm
# Obs.: Usamos %H%S%M para que o valor de segundos e minutos fiquem invertidos em relação ao padrão (%H%M%S)
timestamp=$(date +'%Y%m%d_%H%S%M')
dev_version="${version_without_v}-dev_${timestamp}"
echo "Dev version: $dev_version"
echo "DEV_VERSION=$dev_version" >> $GITHUB_ENV
- name: Update POM Version
run: |
echo "Updating Maven POM version to ${{ env.DEV_VERSION }}"
mvn versions:set -DnewVersion=${{ env.DEV_VERSION }} -DgenerateBackupPoms=false
- name: Setup Java and Maven
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: '17'
server-id: github
settings-path: ${{ github.workspace }}
- name: Configure Maven Settings for GitHub Packages
run: |
mkdir -p $HOME/.m2
cat <<EOF > $HOME/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username>${{ github.actor }}</username>
<password>${{ secrets.GITHUB_TOKEN }}</password>
</server>
</servers>
</settings>
EOF
- name: Build and Deploy to GitHub Packages
run: |
mvn clean install --settings $HOME/.m2/settings.xml
mvn deploy --settings $HOME/.m2/settings.xml