Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 04d8890

Browse files
committed
Try for publish and release only on master, build always
1 parent 174e8ee commit 04d8890

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

.github/workflows/master.yml

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,54 @@
11
name: build and publish
22

33
on:
4-
push:
5-
branches:
6-
- master
4+
- push
5+
- pull_request
6+
77

88
jobs:
9+
setup:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v1
14+
- name: Declare outputs
15+
id: declare
16+
run: |
17+
echo "::set-output name=version::1.$(date +%Y%m%d%H%M%S).$(git describe --always --dirty --exclude '*')"
18+
echo "::set-output name=do_deploy::${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, 'ci skip') }}"
19+
outputs:
20+
version: "${{ steps.declare.outputs.version }}"
21+
do_deploy: "${{ steps.declare.outputs.do_deploy }}"
922
build:
1023
runs-on: ubuntu-latest
24+
needs:
25+
- setup
26+
env:
27+
VERSION: "${{ needs.setup.outputs.version }}"
1128
steps:
1229
- uses: actions/checkout@v1
1330
- uses: actions/setup-java@v1
1431
with:
1532
java-version: '12.x'
1633
- name: test and build
17-
run: ./gradlew -Pversion="1.$(git log -1 --pretty='%h')" build publish
18-
env:
19-
ORG_GRADLE_PROJECT_githubUser: x-access-token
20-
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
34+
run: ./gradlew -Pversion="${VERSION}" build
35+
- name: Save build artifacts
36+
uses: actions/upload-artifact@v2
37+
with:
38+
path: build
2139

2240
release:
2341
name: Create Release
24-
needs: build
42+
needs:
43+
- setup
44+
- build
2545
runs-on: ubuntu-latest
26-
if: github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, 'ci skip')
46+
if: needs.setup.outputs.do_deploy == 'true'
47+
env:
48+
VERSION: "${{ needs.setup.outputs.version }}"
2749
steps:
2850
- name: Checkout code
2951
uses: actions/checkout@v1
30-
- name: Set release tag
31-
run: |
32-
export TAG_NAME="1.$(git log -1 --pretty='%h')"
33-
echo "::set-env name=RELEASE_TAG::$TAG_NAME"
3452
- name: Set changelog
3553
# (Escape newlines see https://github.com/actions/create-release/issues/25)
3654
run: |
@@ -39,14 +57,23 @@ jobs:
3957
text="${text//$'\n'/%0A}"
4058
text="${text//$'\r'/%0D}"
4159
echo "::set-env name=CHANGELOG::$text"
60+
- name: Fetch build artifacts
61+
uses: actions/download-artifact@v2
62+
with:
63+
path: build
64+
- name: publish
65+
run: ./gradlew -Pversion="${VERSION}" publish
66+
env:
67+
ORG_GRADLE_PROJECT_githubUser: x-access-token
68+
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
4269
- name: Create Release
4370
id: create_release
4471
uses: actions/create-release@latest
4572
env:
4673
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4774
with:
48-
tag_name: ${{ env.RELEASE_TAG }}
49-
release_name: ${{ env.RELEASE_TAG }}
75+
tag_name: ${{ env.VERSION }}
76+
release_name: ${{ env.VERSION }}
5077
body: |
5178
Changes in this Release
5279

0 commit comments

Comments
 (0)