-
Notifications
You must be signed in to change notification settings - Fork 14
146 lines (141 loc) · 4.49 KB
/
build-and-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
name: Build and release
on:
push:
branches:
- master
jobs:
build-artifacts:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v2
env:
cache-name: cache-dependencies
with:
path: ~/.gradle/caches
key: build-cache-${{ hashFiles('build.gradle') }}
restore-keys: |
build-cache-
build-
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: '11'
- name: Resolve dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: ./gradlew dependencies
- name: Assemble jar file
run: ./gradlew assemble
- name: Collect artifacts to workspace
run: |
mkdir -p workspace/artifacts
cp ./build/libs/* ./workspace/artifacts/
- name: Upload artifacts to reuse on other workflows
uses: actions/upload-artifact@v2
with:
name: workspace
path: ./**/workspace
publish-as-nightly-build:
runs-on: ubuntu-latest
needs: build-artifacts
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: workspace
- name: Delete existing release
run: hub release delete nightly-build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete existing tag
run: hub push origin :nightly-build
- name: Rename jar file
run: mv ./workspace/artifacts/kGenProg*.jar ./workspace/artifacts/kGenProg-nightly-build.jar
- name: Get current date
id: current-date
run: echo "::set-output name=date::$(date +'%Y/%m/%d %H:%M')"
env:
TZ: Asia/Tokyo
- name: Publish a new nightly-build release
uses: actions/create-release@v1
id: create-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly-build
release_name: Nightly Build (${{ steps.current-date.outputs.date }} JST)
body: |
This is a nightly-build release, automatically built on `master` branch (commit SHA: ${{ github.sha }}).
Execute the following command to download the latest version:
```
$ curl -LO https://github.com/kusumotolab/kGenProg/releases/download/nightly-build/kGenProg-nightly-build.jar
```
draft: false
prerelease: true
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./workspace/artifacts/kGenProg-nightly-build.jar
asset_name: kGenProg-nightly-build.jar
asset_content_type: application/java-archive
- name: Upload artifacts to reuse on other workflows
uses: actions/upload-artifact@v2
with:
name: workspace
path: ./**/workspace/
generate-change-log:
runs-on: ubuntu-latest
needs: publish-as-nightly-build
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: workspace
- name: Set up a Node environment
uses: actions/setup-node@v1
with:
node-version: '12'
- name: Create CHANGELOG.md
run: touch ./workspace/CHANGELOG.md
- name: Generate a change log when needed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x ./.github/generate-change-log.sh
chmod +x ./.github/check-version.sh
./.github/generate-change-log.sh
- name: Upload artifacts to reuse on other workflows
uses: actions/upload-artifact@v2
with:
name: workspace
path: ./**/workspace/
publish-as-new-release:
runs-on: ubuntu-latest
needs: generate-change-log
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Download changelog to reuse on other workflows
uses: actions/download-artifact@v2
with:
name: workspace
- name: Set up a Go environment
uses: actions/setup-go@v2
- name: Publish a new release when needed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_SHA: ${{ github.sha }}
run: |
chmod +x ./.github/publish-new-release.sh
chmod +x ./.github/check-version.sh
./.github/publish-new-release.sh