Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrix-Shen committed Mar 18, 2022
0 parents commit 0d7a8b9
Show file tree
Hide file tree
Showing 37 changed files with 2,700 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
170 changes: 170 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: CI
on:
push:
branches-ignore:
- 'master'
release:
types:
- published
pull_request:
jobs:
build:
if: ${{ github.event_name == 'push' }}
strategy:
matrix:
java: [17]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the sources
uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Get short commit sha
id: get_short_sha
run: |
short_sha=$(echo ${GITHUB_SHA} | cut -c1-7)
echo "::set-output name=short_sha::$short_sha"
- name: Set build number in codes
run: |
sed -i "s/Development/Public Beta/g" src/main/java/top/hendrixshen/bilibilidanmaku/BilibiliDanmakuReference.java
- name: Read relevant fields from gradle.properties
id: properties
run: |
path='./gradle.properties'
for property in mod_name mod_version minecraft_version_out
do
result=$(sed -n "/^[[:space:]]*$property[[:space:]]*=[[:space:]]*/s/^[[:space:]]*$property[[:space:]]*=[[:space:]]*//p" "$path")
echo "$property: $result"
echo ::set-output name=$property::"$result"
done
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
env:
GIT_COMMIT_ID: ${{ steps.get_short_sha.outputs.short_sha }}
run: ./gradlew build
- name: Create Github release
uses: marvinpinto/[email protected]
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "CI/build.${{ github.run_number}}"
prerelease: true
title: "[CI#${{ github.run_number}}]${{ steps.properties.outputs.mod_name }} ${{ steps.properties.outputs.mod_version }}(${{ steps.get_short_sha.outputs.short_sha }}) for Minecraft ${{ steps.properties.outputs.minecraft_version_out }}"
files: |
LICENSE
build/libs/*.jar
publish:
if: ${{ github.event_name == 'release' }}
strategy:
matrix:
java: [17]
os: [ubuntu-latest]
branch: [1.15, 1.16, 1.17, 1.18, 1.19]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the sources
uses: actions/checkout@v2
with:
ref: ${{ matrix.branch }}
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Get commit sha from the corresponding branch
id: get_sha
uses: mego22/actions-git-sha@main
with:
repo: "https://github.com/Hendrix-Shen/Bilibili-Danmaku"
branch: "${{ matrix.branch }}"
- name: Get short commit sha
id: get_short_sha
run: |
short_sha=$(echo ${{ steps.get_sha.outputs.sha }} | cut -c1-7)
echo "::set-output name=short_sha::$short_sha"
- name: Set build number in codes
run: |
sed -i "s/Development/Public Beta/g" src/main/java/top/hendrixshen/bilibilidanmaku/BilibiliDanmakuReference.java
- name: Read relevant fields from gradle.properties
id: properties
run: |
path='./gradle.properties'
for property in mod_file_name mod_version minecraft_version_out cruseforge_gameversion cruseforge_projectid cruseforge_relations cruseforge_release cruseforge_release_type github_release modrinth_release modrinth_release_type
do
result=$(sed -n "/^[[:space:]]*$property[[:space:]]*=[[:space:]]*/s/^[[:space:]]*$property[[:space:]]*=[[:space:]]*//p" "$path")
echo "$property: $result"
echo ::set-output name=$property::"$result"
done
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
env:
GIT_COMMIT_ID: ${{ steps.get_short_sha.outputs.short_sha }}
run: ./gradlew build
- name: Find correct jar
id: findjar
run: |
output="$(find build/libs/ ! -name "*-dev.jar" ! -name "*-sources.jar" -type f -printf "%f\n")"
echo "::set-output name=jarname::$output"
- name: Upload assets to GitHub Release
if: ${{ steps.properties.outputs.github_release == 'true' }}
uses: AButler/[email protected]
with:
files: 'build/libs/${{ steps.findjar.outputs.jarname }}'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload assets to Curseforge
if: ${{ steps.properties.outputs.cruseforge_release == 'true' }}
uses: itsmeow/curseforge-upload@v3
with:
token: ${{ secrets.CF_API_TOKEN }}
project_id: ${{ steps.properties.outputs.cruseforge_projectid }}
game_endpoint: minecraft
file_path: build/libs/${{ steps.findjar.outputs.jarname }}
changelog_type: markdown
changelog: ${{ github.event.release.body }}
game_versions: ${{ steps.properties.outputs.cruseforge_gameversion }}
release_type: ${{ steps.properties.outputs.cruseforge_release_type }}
relations: ${{ steps.properties.outputs.cruseforge_relations }}
- name: Upload assets to Modrinth
if: ${{ steps.properties.outputs.modrinth_release == 'true' }}
run: ./gradlew publishModrinth
env:
CHANGE_LOG: ${{ github.event.release.body }}
GIT_COMMIT_ID: ${{ steps.get_short_sha.outputs.short_sha }}
MODRINTH_API_TOKEN: ${{ secrets.MODRINTH_API_TOKEN }}
VERSION_NUMBER: ${{ steps.properties.outputs.mod_file_name }}-mc${{ steps.properties.outputs.minecraft_version_out }}-${{ steps.properties.outputs.mod_version }}+${{ steps.get_short_sha.outputs.short_sha }}
pull_request:
if: ${{ github.event_name == 'pull_request' }}
strategy:
matrix:
java: [17]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the sources
uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
Loading

0 comments on commit 0d7a8b9

Please sign in to comment.