Skip to content

Commit

Permalink
Update actions for manager
Browse files Browse the repository at this point in the history
  • Loading branch information
rtm516 committed Jun 30, 2024
1 parent 4e95f36 commit a11e3dc
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 84 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ on:
- 'README.md'

jobs:
build-ui:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm ci
working-directory: bootstrap\manager\src\ui
- name: Build
run: npm run build
working-directory: bootstrap\manager\src\ui
- uses: actions/upload-artifact@v3
if: success()
with:
name: UI
path: bootstrap\manager\src\ui\dist
if-no-files-found: error

build:
runs-on: ubuntu-latest
steps:
Expand All @@ -19,6 +40,11 @@ jobs:
distribution: temurin
- name: Checkout repository
uses: actions/checkout@v3
- name: Download UI
uses: actions/download-artifact@v3
with:
name: UI
path: bootstrap/manager/src/main/resources/static
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
Expand Down
218 changes: 147 additions & 71 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,80 +12,121 @@ on:
env:
DOCKER_OWNER: ${{ github.repository_owner }}
DOCKER_CONTAINER: mcxboxbroadcast
DOCKER_CONTAINER_MANAGER: mcxboxbroadcast-manager
DOCKER_TAG: ${{ github.ref_name }}

jobs:
build:
runs-on: ubuntu-latest
steps:
build-ui:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm ci
working-directory: bootstrap/manager/src/ui
- name: Build
run: npm run build
working-directory: bootstrap/manager/src/ui
- uses: actions/upload-artifact@v3
if: success()
with:
name: UI
path: bootstrap/manager/src/ui/dist
if-no-files-found: error

build:
needs: build-ui
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download UI
uses: actions/download-artifact@v3
with:
name: UI
path: bootstrap/manager/src/main/resources/static
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- name: Get previous build number
id: getPreviousBuild
run: |
PREVIOUS_TAG=$(git for-each-ref --sort=-version:refname --count 1 --format="%(refname:short)" "refs/tags/*")
echo result=${PREVIOUS_TAG} >> $GITHUB_OUTPUT
- name: Get current build number
id: getCurrentBuild
if: success()
env:
PREVIOUS_BUILD: ${{ steps.getPreviousBuild.outputs.result }}
run: echo result=$((++PREVIOUS_BUILD)) >> $GITHUB_OUTPUT
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build
gradle-home-cache-cleanup: true
env:
BUILD_NUMBER: ${{ steps.getCurrentBuild.outputs.result }}
- uses: actions/upload-artifact@v3
if: success()
with:
name: MCXboxBroadcastExtension
path: bootstrap/geyser/build/libs/MCXboxBroadcastExtension.jar
if-no-files-found: error
- uses: actions/upload-artifact@v3
if: success()
with:
name: MCXboxBroadcastStandalone
path: bootstrap/standalone/build/libs/MCXboxBroadcastStandalone.jar
if-no-files-found: error
- uses: actions/upload-artifact@v3
if: success()
with:
name: MCXboxBroadcastManager
path: bootstrap/manager/build/libs/MCXboxBroadcastManager.jar
if-no-files-found: error
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
if: success()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ''
custom_tag: ${{ steps.getCurrentBuild.outputs.result }}
- name: Generate release diff
if: success()
env:
BEGIN_COMMIT: ${{ steps.getPreviousBuild.outputs.result }}
END_COMMIT: ${{ steps.getCurrentBuild.outputs.result }}
run: git fetch --tags --force && git log --pretty=format:"* %s (%h)" ${BEGIN_COMMIT}..${END_COMMIT} > release_notes.md
- name: Create release
uses: ncipollo/release-action@v1
if: success()
with:
artifacts: "bootstrap/geyser/build/libs/MCXboxBroadcastExtension.jar,bootstrap/standalone/build/libs/MCXboxBroadcastStandalone.jar,bootstrap/manager/build/libs/MCXboxBroadcastManager.jar,egg-m-c-xbox-broadcast.json"
allowUpdates: true
bodyFile: "release_notes.md"
draft: false
prerelease: false
name: Build ${{ steps.getCurrentBuild.outputs.result }} (${{ github.ref_name }})
tag: ${{ steps.getCurrentBuild.outputs.result }}
token: ${{ secrets.GITHUB_TOKEN }}

docker-standalone:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- name: Get previous build number
id: getPreviousBuild
run: |
PREVIOUS_TAG=$(git for-each-ref --sort=-version:refname --count 1 --format="%(refname:short)" "refs/tags/*")
echo result=${PREVIOUS_TAG} >> $GITHUB_OUTPUT
- name: Get current build number
id: getCurrentBuild
if: success()
env:
PREVIOUS_BUILD: ${{ steps.getPreviousBuild.outputs.result }}
run: echo result=$((++PREVIOUS_BUILD)) >> $GITHUB_OUTPUT
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build
gradle-home-cache-cleanup: true
env:
BUILD_NUMBER: ${{ steps.getCurrentBuild.outputs.result }}
- uses: actions/upload-artifact@v3
if: success()
with:
name: MCXboxBroadcastExtension
path: bootstrap/geyser/build/libs/MCXboxBroadcastExtension.jar
if-no-files-found: error
- uses: actions/upload-artifact@v3
if: success()
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: MCXboxBroadcastStandalone
path: bootstrap/standalone/build/libs/MCXboxBroadcastStandalone.jar
if-no-files-found: error
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
if: success()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ''
custom_tag: ${{ steps.getCurrentBuild.outputs.result }}
- name: Generate release diff
if: success()
env:
BEGIN_COMMIT: ${{ steps.getPreviousBuild.outputs.result }}
END_COMMIT: ${{ steps.getCurrentBuild.outputs.result }}
run: git fetch --tags --force && git log --pretty=format:"* %s (%h)" ${BEGIN_COMMIT}..${END_COMMIT} > release_notes.md
- name: Create release
uses: ncipollo/release-action@v1
if: success()
with:
artifacts: "bootstrap/geyser/build/libs/MCXboxBroadcastExtension.jar,bootstrap/standalone/build/libs/MCXboxBroadcastStandalone.jar,egg-m-c-xbox-broadcast.json"
allowUpdates: true
bodyFile: "release_notes.md"
draft: false
prerelease: false
name: Build ${{ steps.getCurrentBuild.outputs.result }} (${{ github.ref_name }})
tag: ${{ steps.getCurrentBuild.outputs.result }}
token: ${{ secrets.GITHUB_TOKEN }}

# Docker image build
path: bootstrap/standalone/build/libs
- name: Fix Docker environment variables
run: |
# Make lowercase
Expand All @@ -98,14 +139,49 @@ jobs:
- name: Build the Docker image
run: |
docker build . --file Dockerfile --tag $DOCKER_CONTAINER:$DOCKER_TAG
docker build . --file bootstrap/standalone/Dockerfile --tag $DOCKER_CONTAINER:$DOCKER_TAG
[[ "${{ github.ref }}" == "refs/heads/master" ]] && docker tag $DOCKER_CONTAINER:$DOCKER_TAG ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:latest
docker tag $DOCKER_CONTAINER:$DOCKER_TAG ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:$DOCKER_TAG
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

# Disabled for priv
# - name: Push to GHCR
# run: |
# [[ "${{ github.ref }}" == "refs/heads/master" ]] && docker push ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:latest
# docker push ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:$DOCKER_TAG

docker-manager:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: MCXboxBroadcastManager
path: bootstrap/manager/build/libs
- name: Fix Docker environment variables
run: |
# Make lowercase
echo "DOCKER_OWNER=$(echo $DOCKER_OWNER | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
echo "DOCKER_CONTAINER_MANAGER=$(echo $DOCKER_CONTAINER_MANAGER | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
echo "DOCKER_TAG=$(echo $DOCKER_TAG | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
# Replace / with _
echo "DOCKER_TAG=$(echo $DOCKER_TAG | sed -e 's/\//_/g')" >> $GITHUB_ENV
- name: Build the Docker image
run: |
docker build . --file bootstrap/manager/Dockerfile --tag $DOCKER_CONTAINER_MANAGER:$DOCKER_TAG
[[ "${{ github.ref }}" == "refs/heads/master" ]] && docker tag $DOCKER_CONTAINER_MANAGER:$DOCKER_TAG ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER_MANAGER:latest
docker tag $DOCKER_CONTAINER_MANAGER:$DOCKER_TAG ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER_MANAGER:$DOCKER_TAG
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Push to GHCR
run: |
[[ "${{ github.ref }}" == "refs/heads/master" ]] && docker push ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:latest
docker push ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:$DOCKER_TAG
[[ "${{ github.ref }}" == "refs/heads/master" ]] && docker push ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER_MANAGER:latest
docker push ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER_MANAGER:$DOCKER_TAG
14 changes: 14 additions & 0 deletions bootstrap/manager/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM eclipse-temurin:21-alpine

RUN adduser -h /opt/app -H -D app

RUN mkdir -p /opt/app/config && \
chown -R app:app /opt/app

USER app:app

WORKDIR /opt/app/config

COPY bootstrap/manager/build/libs/MCXboxBroadcastManager.jar /opt/app/MCXboxBroadcastManager.jar

CMD ["java", "-jar", "/opt/app/MCXboxBroadcastManager.jar"]

This file was deleted.

File renamed without changes.

0 comments on commit a11e3dc

Please sign in to comment.