-
Notifications
You must be signed in to change notification settings - Fork 766
155 lines (150 loc) · 5.48 KB
/
release.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Publish on release commits
# This workflow detects commits where the message starts with "Release version X.Y.Z".
# It runs tests in parallel before publishing and uploading it.
# When the upload is complete the revision is tagged as a release
# and a script checks whether the artifacts are available.
#
# If the workflow fails any commit with the same version message marker
# will trigger the workflow again.
on:
push:
branches:
- master
jobs:
check-release-job:
name: Check for release marker
runs-on: ubuntu-latest
outputs:
is-release: ${{ steps.check_version.outcome == 'success' }}
release-version-info: ${{ steps.version_info.outputs.VERSION_INFO }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Extract version info
id: version_info
run: echo "VERSION_INFO=`git log --format=%B -n 1 . | egrep '^[rR]elease version' | egrep -o '([[:digit:]]+\.){2}[[:digit:]]+' | xargs -0 printf v%s`" >> $GITHUB_OUTPUT
- name: Check version
id: check_version
if: ${{ steps.version_info.outputs.VERSION_INFO != 'v' }}
env:
VERSION_INFO: ${{ steps.version_info.outputs.VERSION_INFO }}
run: echo $VERSION_INFO
start-release-job:
name: Skip all if not a release
needs: [check-release-job]
if: ${{ needs.check-release-job.outputs.is-release == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Check step
run: echo "Starting a release"
test-job:
name: Run Tests
needs: [start-release-job]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9.16'
- name: Fetch buck
run: |
(rm -rf buck && mkdir buck && \
wget https://jitpack.io/com/github/facebook/buck/v2022.05.05.01/buck-v2022.05.05.01-java11.pex && \
mv buck-v2022.05.05.01-java11.pex buck/buck && \
chmod +x buck/buck && \
ls -l buck)
- name: Run tests
uses: nick-invision/retry@v1
with:
timeout_minutes: 60
max_attempts: 2
command: BUCK_PATH=`realpath buck/buck` ./gradlew test -x :litho-intellij-plugin:test -x :litho-core:test -x :litho-it:test --stacktrace
sample-app-job:
name: Assemble Sample App
needs: [start-release-job]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9.16'
- name: Fetch buck
run: |
(rm -rf buck && mkdir buck && \
wget https://jitpack.io/com/github/facebook/buck/v2022.05.05.01/buck-v2022.05.05.01-java11.pex && \
mv buck-v2022.05.05.01-java11.pex buck/buck && \
chmod +x buck/buck && \
ls -l buck)
- name: Assemble sample app
run: BUCK_PATH=`realpath buck/buck` ./gradlew :sample:assembleRelease --stacktrace
publish-job:
name: Maven Publish
runs-on: ubuntu-latest
needs: [test-job, sample-app-job]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9.16'
- name: Write GPG Sec Ring
run: echo '${{ secrets.GPG_KEY_CONTENTS }}' | base64 -d > /tmp/secring.gpg
- name: Update gradle.properties
run: echo -e "signing.secretKeyRingFile=/tmp/secring.gpg\nsigning.keyId=${{ secrets.SIGNING_KEY_ID }}\nsigning.password=${{ secrets.SIGNING_PASSWORD }}\nmavenCentralPassword=${{ secrets.SONATYPE_NEXUS_PASSWORD }}\nmavenCentralUsername=${{ secrets.SONATYPE_NEXUS_USERNAME }}" >> gradle.properties
- name: Fetch buck
run: |
(rm -rf buck && mkdir buck && \
wget https://jitpack.io/com/github/facebook/buck/v2022.05.05.01/buck-v2022.05.05.01-java11.pex && \
mv buck-v2022.05.05.01-java11.pex buck/buck && \
chmod +x buck/buck && \
ls -l buck)
- name: Upload Android Archives
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache -PforceReleaseBuild=true
- name: Clean secrets
if: always()
run: rm /tmp/secring.gpg
push-tags-job:
name: Push tags if release succeeded
runs-on: ubuntu-latest
needs: [check-release-job, publish-job]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set Git tag
uses: tvdias/[email protected]
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
tag: ${{ needs.check-release-job.outputs.release-version-info }}