Skip to content

Commit

Permalink
[ci-skip] Update workflows (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion authored May 23, 2024
1 parent e0bd782 commit dc96a1e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 107 deletions.
98 changes: 3 additions & 95 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
name: Publish Release
env:
NEXT_BUILD_NUMBER: ${{ vars.NEXT_BUILD_NUMBER }}
BUILD_INITIAL_VALUE: 1
on:
push:
branches:
Expand All @@ -21,41 +18,6 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

# https://github.com/granny/Pl3xMap/blob/1df593e5706444de28fc61855df5a7552afcd3c7/.github/workflows/build.yml#L26
- uses: actions/github-script@v6
name: Prepare build number if it doesn't exist
with:
debug: true
github-token: ${{ secrets.GH_TOKEN }}
script: |
const { owner, repo } = context.repo;
if (process.env.NEXT_BUILD_NUMBER === undefined || process.env.NEXT_BUILD_NUMBER === "") {
core.info(`Could not find a NEXT_BUILD_NUMBER env variable. Creating a new one with value ${process.env.BUILD_INITIAL_VALUE}.`);
const { status, data } = await github.request('POST /repos/{owner}/{repo}/actions/variables', {
owner: owner,
repo: repo,
name: "NEXT_BUILD_NUMBER",
value: process.env.BUILD_INITIAL_VALUE,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
}).catch(err => err.response);
//const { status, data } = await github.rest.actions.createRepoVariable(owner, repo, "NEXT_BUILD_NUMBER", process.env.BUILD_INITIAL_VALUE);
core.debug(JSON.stringify(data, null, 2));
if (data?.message != undefined) {
return core.setFailed(`Failed to update configuration variable NEXT_BUILD_NUMBER with new value of '${process.env.BUILD_INITIAL_VALUE}' for reason ${data.message}`);
}
return core.exportVariable("NEXT_BUILD_NUMBER", process.env.BUILD_INITIAL_VALUE);
} else if (process.env.NEXT_BUILD_NUMBER.split('.').length > 1 || Number.isNaN(Number.parseInt(process.env.NEXT_BUILD_NUMBER))) {
return core.setFailed(`NEXT_BUILD_NUMBER variable has invalid value "${process.env.NEXT_BUILD_NUMBER}", failing build.`);
}
return core.exportVariable("NEXT_BUILD_NUMBER", process.env.NEXT_BUILD_NUMBER);
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3

Expand All @@ -66,7 +28,7 @@ jobs:
java-version: 21
check-latest: true

- name: Gradle Properties Import.
- name: Import gradle properties
id: properties
shell: bash
run: cat gradle.properties >> $GITHUB_ENV
Expand All @@ -82,59 +44,5 @@ jobs:
env:
HANGAR_KEY: ${{ secrets.HANGAR_KEY }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: ./gradlew modrinth publishAllPublicationsToHangar --stacktrace

- name: Build Succeeded
uses: sarisia/actions-status-discord@v1
if: success()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
noprefix: true
nodetail: true
title: A new version of CrazyCrates is ready.
color: 0xE91E63
description: |
* <:hangar:1139326635313733652> https://hangar.papermc.io/CrazyCrew/CrazyCrates/versions/${{ env.version }}-${{ env.NEXT_BUILD_NUMBER }}
* <:modrinth:1115307870473420800> https://modrinth.com/plugin/crazycrates/version/${{ env.version }}-${{ env.NEXT_BUILD_NUMBER }}
- name: Build Failed
uses: sarisia/actions-status-discord@v1
if: ${{ failure() }}
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
noprefix: true
nodetail: true
title: The build didn't survive.
color: 0xff0000
description: |
Version ${{ env.version }} build ${{ env.NEXT_BUILD_NUMBER }} has died.
Click [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) to view the run.
# https://github.com/granny/Pl3xMap/blob/1df593e5706444de28fc61855df5a7552afcd3c7/.github/workflows/build.yml#L95
- uses: actions/github-script@v6
name: Increment Build Number
if: success()
with:
debug: true
github-token: ${{ secrets.GH_TOKEN }}
script: |
const { owner, repo } = context.repo;
const value = '' + (${{ env.NEXT_BUILD_NUMBER }} + 1);
core.info(`attempting to update variable 'NEXT_BUILD_NUMBER' to '${value}'.`);
const { status, data } = await github.request('PATCH /repos/{owner}/{repo}/actions/variables/{name}', {
owner: owner,
repo: repo,
name: "NEXT_BUILD_NUMBER",
value: value,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
}).catch(err => err.response);
//const { data } = await github.rest.actions.updateRepoVariable(owner, repo, "NEXT_BUILD_NUMBER", value)
core.debug(JSON.stringify(data, null, 2));
if (data?.message != undefined) {
return core.setFailed(`Failed to update configuration variable NEXT_BUILD_NUMBER with new value of '${value}'`);
}
COMMIT_MESSAGE: ${{ join(github.event.commits.*.message, '<br>* ') }}
run: ./gradlew modrinth publishAllPublicationsToHangar --stacktrace
14 changes: 3 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import com.ryderbelserion.feather.tools.formatLog
import com.ryderbelserion.feather.tools.latestCommitHash
import com.ryderbelserion.feather.tools.latestCommitMessage

plugins {
alias(libs.plugins.minotaur)
alias(libs.plugins.hangar)
Expand All @@ -11,15 +7,11 @@ plugins {

val buildNumber: String = System.getenv("NEXT_BUILD_NUMBER") ?: "SNAPSHOT"

val isSnapshot = true
val isSnapshot = false

rootProject.version = if (isSnapshot) "3.0-$buildNumber" else "3.0"
rootProject.version = "3.0"

val content: String = if (isSnapshot) {
formatLog(latestCommitHash(), latestCommitMessage(), rootProject.name, "Crazy-Crew")
} else {
rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8)
}
val content: String = rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8)

subprojects.filter { it.name != "api" }.forEach {
it.project.version = rootProject.version
Expand Down
2 changes: 1 addition & 1 deletion paper/run/server.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Minecraft server properties
#Sun May 19 16:52:58 EDT 2024
#Thu May 23 14:31:31 EDT 2024
accepts-transfers=false
allow-flight=false
allow-nether=false
Expand Down

0 comments on commit dc96a1e

Please sign in to comment.