Merge pull request #14 from allclients2/main #37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Java CI with Gradle | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
LATEST_VERSION: "1.21" | |
INCLUDE_DEVLIBS: "true" | |
# Warning: Don't add too many versions because it takes a lot of space in the artifacts, | |
# and I've gotten an email from GitHub about it so please just don't. | |
VERSIONS_TO_BUILD: "1.16.5 1.17.1 1.18.2 1.20.4 1.21" | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '21' | |
distribution: 'adopt' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Create versions directory and mainProject | |
run: | | |
mkdir -p ./versions | |
if [ ! -f ./versions/mainProject ]; then | |
echo $LATEST_VERSION > ./versions/mainProject | |
fi | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Create artifact directory structure | |
run: | | |
mkdir -p artifacts | |
for version in $VERSIONS_TO_BUILD; do | |
mkdir -p artifacts/$version/libs | |
cp ./versions/$version/build/libs/*.jar artifacts/$version/libs/ | |
if [ "$INCLUDE_DEVLIBS" = "true" ]; then | |
mkdir -p artifacts/$version/devlibs | |
cp ./versions/$version/build/devlibs/*.jar artifacts/$version/devlibs/ | |
fi | |
done | |
- name: Compute hashes | |
run: | | |
touch artifacts/hashes.txt | |
for jar in $(find artifacts -name '*.jar'); do | |
sha256sum $jar >> artifacts/hashes.txt | |
done | |
- name: Archive Artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: Artifacts | |
path: artifacts |