fix api publishing #304
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: CI | |
on: | |
push: | |
branches: | |
- '**' | |
workflow_dispatch: | |
jobs: | |
# the problem is that the numbers are going to be masked because of the secrets | |
get_major_version: | |
runs-on: ubuntu-latest | |
name: "Get version" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get major version | |
id: getMajorVersion | |
run: | | |
MINECRAFT_VERSION=$(grep MAJOR_VERSION buildSrc/src/main/kotlin/net/blueberrymc/gradle/buildSrc/constants/MagicConstants.kt | sed -r "s/.*= \"([0-9]+\\.[0-9]+)(\\.[0-9]+)?\"/\1/" | sed s/\\./_/) | |
echo "Detected major version: $MINECRAFT_VERSION" | |
echo "value=$MINECRAFT_VERSION" >> $GITHUB_OUTPUT | |
outputs: | |
major_version: ${{ steps.getMajorVersion.outputs.value }} | |
update_build_number: | |
runs-on: ubuntu-latest | |
name: "Update build number" | |
needs: | |
- get_major_version | |
env: | |
MAJOR_VERSION: ${{ needs.get_major_version.outputs.major_version }} | |
steps: | |
- name: Generate next build number | |
run: 'echo "value=$(($BN + 1))" >> $GITHUB_OUTPUT' | |
id: generateNextBuildNumber | |
env: | |
BN: ${{ secrets[format('BUILD_NUMBER_{0}', env.MAJOR_VERSION)] }} | |
- uses: BlueberryMC/actions-set-secret@v3.0.3 | |
with: | |
name: ${{ format('BUILD_NUMBER_{0}', env.MAJOR_VERSION) }} | |
value: ${{ steps.generateNextBuildNumber.outputs.value }} | |
token: ${{ secrets.TOKEN }} | |
- run: "echo 'Current build number (this number will be masked!): '$CBN', next build number: '$NBN" | |
env: | |
CBN: ${{ secrets[format('BUILD_NUMBER_{0}', env.MAJOR_VERSION)] }} | |
NBN: ${{ steps.generateNextBuildNumber.outputs.value }} | |
outputs: | |
major_version: ${{ env.MAJOR_VERSION }} | |
gradle-build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: [ '21' ] | |
name: "Gradle (Java ${{ matrix.Java }})" | |
needs: | |
- get_major_version | |
- update_build_number | |
env: | |
MAJOR_VERSION: ${{ needs.update_build_number.outputs.major_version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup git | |
run: 'git config --global user.email "actions@github.com" && git config --global user.name "GitHub Actions"' | |
- name: Setup Java JDK | |
uses: actions/setup-java@v3.10.0 | |
with: | |
java-version: ${{ matrix.java }} | |
distribution: temurin | |
#cache: 'gradle' | |
# - name: Update submodules | |
# run: "git submodule update --init && cd MagmaCube && git submodule update --init && cd .." | |
- name: "Prepare Minecraft environment" | |
run: './gradlew prepareMinecraft --info --stacktrace' | |
- name: "Apply patches (Blueberry)" | |
run: './gradlew applyBlueberryPatches --info --stacktrace' | |
- name: Run test | |
run: './gradlew -PBUILD_NUMBER=$BUILD_NUMBER test --info --stacktrace' | |
env: | |
BUILD_NUMBER: ${{ secrets[format('BUILD_NUMBER_{0}', env.MAJOR_VERSION)] }} | |
- name: Prepare gradle.properties | |
run: | | |
mkdir -p $HOME/.gradle | |
echo "blueberryRepoUsername=${{ secrets.REPO_USERNAME }}" >> $HOME/.gradle/gradle.properties | |
echo "blueberryRepoPassword=${{ secrets.REPO_PASSWORD }}" >> $HOME/.gradle/gradle.properties | |
echo "blueberryRepo2Username=${{ secrets.REPO_USERNAME }}" >> $HOME/.gradle/gradle.properties | |
echo "blueberryRepo2Password=${{ secrets.REPO_PASSWORD }}" >> $HOME/.gradle/gradle.properties | |
- name: Deploy API to repository | |
run: ./gradlew -PBUILD_NUMBER=$BUILD_NUMBER publish | |
- name: Bake installer | |
run: './gradlew -PBUILD_NUMBER=$BUILD_NUMBER bakeInstaller --info --stacktrace' | |
env: | |
BUILD_NUMBER: ${{ secrets[format('BUILD_NUMBER_{0}', env.MAJOR_VERSION)] }} | |
- name: Retrieve mc + api + build number version | |
run: 'echo "version=$(./gradlew -q --console plain -PBUILD_NUMBER=$BUILD_NUMBER printVersion)" >> $GITHUB_OUTPUT' | |
id: retrieveVersion | |
env: | |
BUILD_NUMBER: ${{ secrets[format('BUILD_NUMBER_{0}', env.MAJOR_VERSION)] }} | |
- name: Retrieve mc + api version | |
run: 'echo "version=$(./gradlew -q --console plain printVersion)" >> $GITHUB_OUTPUT' | |
id: retrieveApiVersion | |
- name: Release new build | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.retrieveVersion.outputs.version }} | |
files: '*-installer.jar' | |
target_commitish: ${{ github.sha }} | |
fail_on_unmatched_files: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
prerelease: ${{ !startsWith(github.ref_name, 'ver/') && github.ref_name != 'main' && github.ref_name != 'master' }} | |
- name: Update release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.retrieveApiVersion.outputs.version }} | |
files: '*-installer.jar' | |
target_commitish: ${{ github.sha }} | |
fail_on_unmatched_files: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
prerelease: ${{ !startsWith(github.ref_name, 'ver/') && github.ref_name != 'main' && github.ref_name != 'master' }} | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v3.1.2 | |
with: | |
name: blueberry-installer-java-${{ matrix.java }} | |
path: '*-installer.jar' | |
- name: Deploy build | |
run: | | |
V=${V%.*} | |
curl -X PUT -H "Authorization: Bearer ${{ secrets.DEPLOY_SECRET_KEY }}" "https://api.blueberrymc.net/v1/projects/blueberry/version_groups/well_anything_can_be_put_here/builds/${{ secrets[format('BUILD_NUMBER_{0}', env.MAJOR_VERSION)] }}/new?repo=${{ github.repository }}&commit=${{ github.sha }}&versionGroup=${{ env.MAJOR_VERSION }}&version=$V&branch=${{ github.ref_name }}" | |
env: | |
V: ${{ steps.retrieveVersion.outputs.version }} |