Skip to content

CI

CI #1422

Workflow file for this run

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@v3
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 github-actions@github.com
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