forked from MCXboxBroadcast/Broadcaster
-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (131 loc) · 4.99 KB
/
Copy pathrelease.yml
File metadata and controls
155 lines (131 loc) · 4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Build Release
on:
workflow_dispatch:
push:
branches:
- "master"
paths-ignore:
- '.gitignore'
- 'LICENSE'
- 'README.md'
- '.github/**'
- '!.github/workflows/release.yml'
env:
DOCKER_OWNER: ${{ github.repository_owner }}
DOCKER_CONTAINER: standalone
DOCKER_TAG: ${{ github.ref_name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v5
- name: Set up JDK 17
uses: actions/setup-java@v5
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: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
gradle-home-cache-cleanup: true
- name: Build
run: ./gradlew build
env:
BUILD_NUMBER: ${{ steps.getCurrentBuild.outputs.result }}
- uses: actions/upload-artifact@v7
if: success()
with:
name: MCXboxBroadcastExtension
path: bootstrap/geyser/build/libs/MCXboxBroadcastExtension.jar
if-no-files-found: error
- uses: actions/upload-artifact@v7
if: success()
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/github-tag-action@v6.2
if: ${{ success() && github.ref_name == 'master' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ''
custom_tag: ${{ steps.getCurrentBuild.outputs.result }}
- name: Generate release diff
if: ${{ success() && github.ref_name == 'master' }}
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: Publish to Modrinth
if: ${{ success() && github.repository == 'MCXboxBroadcast/Broadcaster' && github.ref_name == 'master' }}
run: ./gradlew :bootstrap-geyser:modrinth
env:
BUILD_NUMBER: ${{ steps.getCurrentBuild.outputs.result }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
- name: Create release
uses: ncipollo/release-action@v1
if: ${{ success() && github.ref_name == 'master' }}
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-standalone:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v7
with:
name: MCXboxBroadcastStandalone
path: bootstrap/standalone/build/libs
- name: Make environment variables lowercase
run: |
echo "DOCKER_OWNER=$(echo $DOCKER_OWNER | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
echo "DOCKER_CONTAINER=$(echo $DOCKER_CONTAINER | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
echo "DOCKER_TAG=$(echo $DOCKER_TAG | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
- name: Fix Docker tag format
run: |
# Replace / with _
echo "DOCKER_TAG=$(echo $DOCKER_TAG | sed -e 's/\//_/g')" >> $GITHUB_ENV
- name: Set Docker container tags
run: |
DOCKER_TAGS="ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:$DOCKER_TAG"
[[ "${{ github.ref }}" == "refs/heads/master" ]] && DOCKER_TAGS="$DOCKER_TAGS,ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:latest"
echo "DOCKER_TAGS=$DOCKER_TAGS" >> "$GITHUB_ENV"
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: bootstrap/standalone/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_TAGS }}