name: Build AsminVoicechat run-name: Build AsminVoicechat on: push: branches: - main - master workflow_dispatch: concurrency: group: asmin-voicechat-release cancel-in-progress: false jobs: prepare-release: runs-on: docker-builder outputs: version: ${{ steps.version.outputs.version }} tag: ${{ steps.version.outputs.tag }} release_id: ${{ steps.release.outputs.release_id }} steps: - name: Checkout repository and tags uses: actions/checkout@v4 with: fetch-depth: 0 - name: Calculate next version id: version shell: bash run: | latest="$(git tag --list 'v[0-9]*' --sort=-version:refname | head -n 1)" if [[ -z "$latest" ]]; then version="1.0.0" else current="${latest#v}" IFS='.' read -r major minor patch <<< "$current" if (( patch >= 9 )); then version="$major.$((minor + 1)).0" else version="$major.$minor.$((patch + 1))" fi fi echo "version=$version" >> "$GITHUB_OUTPUT" echo "tag=v$version" >> "$GITHUB_OUTPUT" - name: Create Gitea release id: release env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_SERVER_URL: ${{ gitea.server_url }} GITEA_REPOSITORY: ${{ gitea.repository }} VERSION: ${{ steps.version.outputs.version }} TAG: ${{ steps.version.outputs.tag }} shell: bash run: | set -euo pipefail if [[ -z "$GITEA_TOKEN" ]]; then echo "Add a repository write token as the GITEA_TOKEN secret." exit 1 fi api="$GITEA_SERVER_URL/api/v1/repos/$GITEA_REPOSITORY" release="$(curl --fail-with-body -sS -X POST "$api/releases" \ -H "Authorization: token $GITEA_TOKEN" \ -H 'Content-Type: application/json' \ -d "{\"tag_name\":\"$TAG\",\"name\":\"AsminVoiceChat $VERSION\",\"body\":\"Dual-protocol Simple Voice Chat server release.\",\"draft\":false,\"prerelease\":false}")" release_id="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])' <<< "$release")" echo "release_id=$release_id" >> "$GITHUB_OUTPUT" build-and-test: needs: prepare-release runs-on: docker-builder strategy: fail-fast: false matrix: java: - '16' - '17' - '18' - '19' - '20' - '21' - '22' - '23' - '24' - '25' - '26' - '27-ea' steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Java ${{ matrix.java }} uses: actions/setup-java@v4 with: distribution: temurin java-version: ${{ matrix.java }} - name: Download 2.6.25 base and compile dependencies shell: bash run: | set -euo pipefail mkdir -p build/deps build/classes build/test-classes hangar="https://hangarcdn.papermc.io/plugins/henkelmax/SimpleVoiceChat/versions/bukkit-2.6.25/PAPER/voicechat-bukkit-2.6.25.jar" curl --fail --location --silent --show-error "$hangar" -o build/deps/voicechat-bukkit-2.6.25.jar repo="https://repo.papermc.io/repository/maven-public" curl --fail --location --silent --show-error "$repo/io/papermc/paper/paper-api/1.17.1-R0.1-SNAPSHOT/paper-api-1.17.1-R0.1-20220414.034903-311.jar" -o build/deps/paper-api.jar curl --fail --location --silent --show-error "$repo/net/md-5/bungeecord-chat/1.16-R0.4/bungeecord-chat-1.16-R0.4.jar" -o build/deps/bungeecord-chat.jar curl --fail --location --silent --show-error "$repo/net/kyori/adventure-api/4.9.3/adventure-api-4.9.3.jar" -o build/deps/adventure-api.jar curl --fail --location --silent --show-error "$repo/net/kyori/adventure-key/4.9.3/adventure-key-4.9.3.jar" -o build/deps/adventure-key.jar curl --fail --location --silent --show-error "$repo/net/kyori/examination-api/1.3.0/examination-api-1.3.0.jar" -o build/deps/examination-api.jar curl --fail --location --silent --show-error "$repo/net/kyori/examination-string/1.3.0/examination-string-1.3.0.jar" -o build/deps/examination-string.jar curl --fail --location --silent --show-error "$repo/org/jetbrains/annotations/22.0.0/annotations-22.0.0.jar" -o build/deps/annotations.jar curl --fail --location --silent --show-error "$repo/io/netty/netty-buffer/4.1.63.Final/netty-buffer-4.1.63.Final.jar" -o build/deps/netty-buffer.jar curl --fail --location --silent --show-error "$repo/io/netty/netty-common/4.1.63.Final/netty-common-4.1.63.Final.jar" -o build/deps/netty-common.jar - name: Compile Java 8-compatible patch classes env: VERSION: ${{ needs.prepare-release.outputs.version }} shell: bash run: | set -euo pipefail cp="build/deps/voicechat-bukkit-2.6.25.jar:$(printf '%s:' build/deps/*.jar)" javac --release 8 -cp "$cp" -d build/classes \ source/patch/de/maxhenkel/voicechat/voice/common/Secret.java \ source/patch/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.java sed "s/^version:.*/version: '$VERSION'/" plugin.yml > build/plugin.yml python3 - <<'PY' from pathlib import Path from zipfile import ZIP_DEFLATED, ZipFile base = Path("build/deps/voicechat-bukkit-2.6.25.jar") target = Path("build/AsminVoiceChat-${{ needs.prepare-release.outputs.version }}.jar") replacements = { "de/maxhenkel/voicechat/voice/common/Secret.class": Path("build/classes/de/maxhenkel/voicechat/voice/common/Secret.class"), "de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.class": Path("build/classes/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.class"), "plugin.yml": Path("build/plugin.yml"), } with ZipFile(base) as source, ZipFile(target, "w", ZIP_DEFLATED) as output: for item in source.infolist(): replacement = replacements.get(item.filename) output.writestr(item, replacement.read_bytes() if replacement else source.read(item.filename)) print(f"Built {target}") PY - name: Run CBC/GCM interoperability test shell: bash run: | set -euo pipefail cp="build/AsminVoiceChat-${{ needs.prepare-release.outputs.version }}.jar:build/deps/netty-buffer.jar:build/deps/netty-common.jar" javac --release 8 -cp "$cp" -d build/test-classes tests/ProtocolCryptoSelfTest.java java -cp "build/test-classes:$cp" ProtocolCryptoSelfTest - name: Upload JVM-specific build to release env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_SERVER_URL: ${{ gitea.server_url }} GITEA_REPOSITORY: ${{ gitea.repository }} RELEASE_ID: ${{ needs.prepare-release.outputs.release_id }} VERSION: ${{ needs.prepare-release.outputs.version }} JAVA_VERSION: ${{ matrix.java }} shell: bash run: | set -euo pipefail api="$GITEA_SERVER_URL/api/v1/repos/$GITEA_REPOSITORY" file="build/AsminVoiceChat-${VERSION}.jar" asset="AsminVoiceChat-${VERSION}-Java${JAVA_VERSION}.jar" curl --fail-with-body -sS -X POST "$api/releases/$RELEASE_ID/assets?name=$asset" \ -H "Authorization: token $GITEA_TOKEN" \ -F "attachment=@$file;filename=$asset" if [[ "$JAVA_VERSION" == "21" ]]; then curl --fail-with-body -sS -X POST "$api/releases/$RELEASE_ID/assets?name=AsminVoiceChat-${VERSION}.jar" \ -H "Authorization: token $GITEA_TOKEN" \ -F "attachment=@$file;filename=AsminVoiceChat-${VERSION}.jar" fi