-
Notifications
You must be signed in to change notification settings - Fork 33
135 lines (112 loc) · 4.64 KB
/
deploy-prod.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: GLPI Android Inventory Agent Release
env:
module_app: app
on:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0 #To Fetch All Tags and Branches
################################
# Update Version Code #
################################
- name: Update Android Version code
run: ./gradlew updateVersionCode
- name: "Extract Current Tag Name"
run: echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: "Update Release Version"
run: echo "$(jq '.version = "${{ env.tag_name }}"' package.json)" > package.json
- name: Extract App VersionCode
run: echo "app_version_code=$(grep versionCode ./app/src/main/AndroidManifest.xml | cut -d\" -f2)" >> $GITHUB_ENV
- name: Extract Previous Tag Name
run: echo "previous_tag_name=$(git tag --sort=taggerdate | tail -1)" >> $GITHUB_ENV
- name: Update About Data
run : |
echo "about.version=${{ env.tag_name }}" > ./app/src/main/assets/about.properties
echo "about.build=${{ env.app_version_code }}" >> ./app/src/main/assets/about.properties
echo "about.date=$(date "+%a %b %d %H:%M:%S %Y")" >> ./app/src/main/assets/about.properties
echo "about.commit=$(git rev-parse --short "$GITHUB_SHA")" >> ./app/src/main/assets/about.properties
echo "about.commitFull=$(git rev-parse "$GITHUB_SHA")" >> ./app/src/main/assets/about.properties
echo "about.github=https://github.com/glpi-project/android-inventory-agent" >> ./app/src/main/assets/about.properties
- name: Update main branch
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
add: "['CHANGELOG.md', 'package.json']" #only this files will be added
push: origin HEAD:main
message: "ci(release): release new version ${{ env.tag_name }}"
##########################################
# Push / Pull translation files #
##########################################
# Push Transifex
- name: Push source file using transifex client
uses: transifex/cli-action@v2
with:
args: push
token: ${{ secrets.TX_TOKEN }}
# Clean Transifex CLI
- name: Clean Transifex CLI
run: rm -fr /tmp/tx
# Pull from Transifex
- name: Pull source file using transifex client
uses: transifex/cli-action@v2
with:
args: pull --force --all --minimum-perc=80
token: ${{ secrets.TX_TOKEN }}
###############################
# Prepare / Build project #
###############################
# Grant execute permission for gradlew
- name: Grant Execute Permission For Gradlew
run: chmod +x gradlew
# assemble app
- name: Build with Gradle
run: ./gradlew assemble
# Build app
- name: Build with Gradle
run: ./gradlew build
- name: Setup build tool version variable
shell: bash
run: |
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
echo Last build tool version is: $BUILD_TOOL_VERSION
- name: Sign app APK
uses: r0adkll/sign-android-release@v1
# ID used to access action output
id: sign_app
with:
releaseDirectory: app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGN_APK_SIGNING_KEY }}
alias: ${{ secrets.SIGN_APK_ALIAS }}
keyStorePassword: ${{ secrets.SIGN_APP_STOREPASS }}
keyPassword: ${{ secrets.SIGN_APP_KEYPASS }}
env:
# override default build-tools version (29.0.3) -- optional
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
- name: Push to google play
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_CONSOLE }}
packageName: org.glpi.inventory.agent
releaseFiles: app/build/outputs/apk/release/app-release-unsigned-signed.apk
track: production
#####################
# Prepare release #
#####################
- name: "Rename APK"
run: mv app/build/outputs/apk/release/app-release-unsigned-signed.apk app/build/outputs/apk/release/android-inventory-agent-v${{ env.tag_name }}.apk
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name : Android Inventory Agent v${{ env.tag_name }}
draft : true
body : See CHANGELOG.md
files: app/build/outputs/apk/release/android-inventory-agent-v${{ env.tag_name }}.apk