forked from emilymclean/JetpackForms
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (139 loc) · 4.85 KB
/
build.yml
File metadata and controls
145 lines (139 loc) · 4.85 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
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
136
137
138
139
140
141
142
143
144
145
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Build
on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.gitversion.outputs.semVer }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
configFilePath: ./GitVersion.yml
- name: Display SemVer
run: |
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: -Pversion=${{ steps.gitversion.outputs.semVer }} forms:build
- uses: actions/upload-artifact@master
with:
name: forms-aar
path: ./forms/build/outputs/aar/forms-release.aar
publish-pre:
needs: build
if: ${{ github.ref == 'refs/heads/develop' }}
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- uses: actions/download-artifact@master
with:
name: forms-aar
path: ./forms/build/outputs/aar/
- name: release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: true
tag_name: pre/v${{ needs.build.outputs.version }}
release_name: Prerelease ${{ needs.build.outputs.version }}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: upload artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./forms/build/outputs/aar/forms-release.aar
asset_name: forms.aar
asset_content_type: application/zip
publish-release:
needs: build
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- uses: actions/download-artifact@master
with:
name: forms-aar
path: ./forms/build/outputs/aar/
- name: release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
tag_name: v${{ needs.build.outputs.version }}
release_name: Release ${{ needs.build.outputs.version }}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: upload artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./forms/build/outputs/aar/forms-release.aar
asset_name: forms.aar
asset_content_type: application/zip
publish-package:
needs: [build, publish-pre, publish-release]
if: ${{ always() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: -Pversion=${{ needs.build.outputs.version }} forms:build
- name: Publish to GitHub Packages
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: -Pversion=${{ needs.build.outputs.version }} forms:publish
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}