-
-
Notifications
You must be signed in to change notification settings - Fork 11
136 lines (132 loc) · 5.02 KB
/
ci.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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule: [ cron: '2 3 * * *' ] # every day, 03:02
workflow_dispatch: # trigger workflow run manually
jobs:
setup:
runs-on: ubuntu-latest
outputs:
date: ${{ steps.version.outputs.date }}
datetime: ${{ steps.version.outputs.datetime }}
sha: ${{ steps.version.outputs.sha }}
tag: ${{ steps.version.outputs.tag }}
version: ${{ steps.version.outputs.version }}
steps:
- name: 'Compute version string'
id: version
run: |
DATE=$(date -u '+%Y.%m.%d')
DATETIME=$(date -u '+%Y.%m.%d.%H.%M.%S')
echo "date=${DATE}" >> $GITHUB_OUTPUT
echo "datetime=${DATETIME}" >> $GITHUB_OUTPUT
SHA=$(echo "${{ github.sha }}" | cut -c1-7)
TAG=0-ea
VERSION=${TAG}+${SHA}
echo "sha=${SHA}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
build:
needs: [ setup ]
runs-on: ubuntu-latest
steps:
- name: 'Check out repository'
uses: actions/checkout@v4
- name: 'Set up Java'
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: 21
- name: 'Get bucket size'
id: bucket
run: |
SIZE=$(aws s3api list-objects-v2 --bucket java9plusadoption --region us-east-1 --no-sign-request --query "[length(Contents[])]" --output json | jq '.[]')
echo SIZE = ${SIZE}
echo "size=$(echo ${SIZE})" >> $GITHUB_OUTPUT
- name: 'Cache bucket'
id: cache-bucket
uses: actions/cache@v4
with:
path: bucket
key: bucket-${{ steps.bucket.outputs.size }}
restore-keys: bucket-
- name: 'Sync bucket'
if: steps.cache-bucket.outputs.cache-hit != 'true'
run: |
mkdir --parents bucket
du --bytes bucket
aws s3 sync s3://java9plusadoption bucket --region us-east-1 --no-sign-request --only-show-errors
du --bytes bucket
- name: 'Find interesting projects in bucket'
run: |
java \
-Xmx5G \
src/Database.java \
bucket
- name: 'Scan bucket'
run: |
java \
-Xmx5G \
-Dbadges=true \
-Ddoc=true \
-Dillegal-automatic-module-names=true \
-Dimpostor-modules=true \
src/Scanner.java \
bucket \
com.github.sormuras.modules/com/github/sormuras/modules/modules.properties
- name: 'Count modules'
id: count-modules
run: echo "size=$(wc --lines < com.github.sormuras.modules/com/github/sormuras/modules/modules.properties)" >> $GITHUB_OUTPUT
- name: 'Build with Bach'
run: |
PATH=.bach/bin:$PATH
bach --project-version ${{ needs.setup.outputs.version }} build
- name: 'Check for modifications'
id: git-status
run: |
git status
echo "modified=$(if [[ -z $(git status --porcelain) ]]; then echo 'false'; else echo 'true'; fi)" >> $GITHUB_OUTPUT
- name: 'Commit and push changes'
if: steps.git-status.outputs.modified == 'true'
run: |
git config user.name github-actions
git config user.email [email protected]
git add .
git commit --message '${{ steps.count-modules.outputs.size }} unique modules (${{ needs.setup.outputs.date }})'
git push
- name: 'Release ${{ needs.setup.outputs.tag }}'
if: steps.git-status.outputs.modified == 'true'
uses: jreleaser/release-action@v1
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: early-access
arguments: |
release \
--auto-config \
--overwrite \
--tag-name=${{ needs.setup.outputs.tag }} \
--prerelease \
--project-name=com.github.sormuras.modules \
--project-version=${{ needs.setup.outputs.version }} \
--release-name="${{ needs.setup.outputs.version }} with ${{ steps.count-modules.outputs.size }} modules" \
--file .bach/workspace/logbook.md \
--file .bach/workspace/modules/com.github.sormuras.modules@${{ needs.setup.outputs.tag }}.jar \
--file com.github.sormuras.modules/com/github/sormuras/modules/modules.properties
- name: 'Upload artifact ${{ github.event.repository.name }}-build-${{ needs.setup.outputs.version }}'
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-build-${{ needs.setup.outputs.version }}
path: |
.bach/workspace/logbook.md
.bach/workspace/modules
com.github.sormuras.modules/com/github/sormuras/modules/modules.properties
out/composable-modules.txt
out/total-requires.txt
out/unknown-requires.txt
out/jreleaser/trace.log
out/*.properties