diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..521d1df --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:base"], + "rangeStrategy": "bump", + "labels": ["dependencies"], + "packageRules": [ + { + "matchUpdateTypes": ["minor", "patch"], + "automerge": true + }, + { + "matchDepTypes": ["devDependencies"], + "automerge": true + } + ] +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c5b4c1f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,86 @@ +name: Build +on: + release: + types: [created] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set Environment Variables + run: | + IMG=lavalink + OWNER="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')" + echo "IMG=${IMG}" >> $GITHUB_ENV + echo "IMAGE=ghcr.io/${OWNER}/${IMG}" >> $GITHUB_ENV + echo "VERSION=$GITHUB_REF_NAME" >> $GITHUB_ENV + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Java v17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '17' + + - name: Download & Repack Lavalink.jar + run: | + wget https://github.com/freyacodes/Lavalink/releases/download/${{ env.VERSION }}/Lavalink.jar + wget https://github.com/aikaterna/lavaplayer-natives/raw/master/linux-aarch64/libconnector.so + mkdir -p Lavalink-patch/lavaplayer-natives-patch; pushd Lavalink-patch + unzip ../Lavalink.jar + pushd lavaplayer-natives-patch + unzip ../BOOT-INF/lib/lavaplayer-natives*.jar + mkdir -p natives/linux-aarch64/ + cp ../../libconnector.so natives/linux-aarch64 + jar -cvfm ../BOOT-INF/lib/lavaplayer-natives*.jar META-INF/MANIFEST.MF . + popd; rm -rf lavaplayer-natives-patch + jar -cvf0m ../LavalinkPatch.jar META-INF/MANIFEST.MF . + popd; rm -rf Lavalink-patch + + - name: Release LavalinkPatch.jar + uses: softprops/action-gh-release@v1 + with: + files: LavalinkPatch.jar + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/arm64 + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: | + ${{ env.IMAGE }}:${{ env.VERSION }} + ${{ env.IMAGE }}:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..7a6637d --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,26 @@ +name: Check releases +on: + schedule: + - cron: '0 * * * *' + workflow_dispatch: + +jobs: + check: + runs-on: ubuntu-latest + env: + LAVALINK_REPO: freyacodes/Lavalink + GITHUB_TOKEN: ${{ secrets.GH_PAT_TOKEN }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Node v16 + uses: actions/setup-node@v2 + with: + node-version: 16 + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Run check + run: yarn start diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6704566 --- /dev/null +++ b/.gitignore @@ -0,0 +1,104 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2349d69 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM eclipse-temurin:17 + +# Run as non-root user +RUN groupadd -g 322 lavalink && \ + useradd -r -u 322 -g lavalink lavalink +USER lavalink + +WORKDIR /opt/Lavalink + +COPY LavalinkPatch.jar Lavalink.jar + +ENTRYPOINT ["java", "-Djdk.tls.client.protocols=TLSv1.1,TLSv1.2", "-Xmx4G", "-jar", "Lavalink.jar"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c2741f6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Despenser Team + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..62dddc4 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Lavalink-arm64 + +Lavalink arm64 build diff --git a/index.js b/index.js new file mode 100644 index 0000000..f7f59c0 --- /dev/null +++ b/index.js @@ -0,0 +1,39 @@ +const { default: axios } = require("axios"); + +async function main() { + const lavalink = await axios + .get(`${process.env.GITHUB_API_URL}/repos/${process.env.LAVALINK_REPO}/releases`, { + headers: { Accept: "application/vnd.github.v3+json", "User-Agent": "Node.js" }, + }) + .then((res) => res.data); + + const github = await axios + .get(`${process.env.GITHUB_API_URL}/repos/${process.env.GITHUB_REPOSITORY}/releases`, { + headers: { Accept: "application/vnd.github.v3+json", "User-Agent": "Node.js" }, + }) + .then((res) => res.data); + + if (!lavalink || lavalink.length < 1) return console.error("Failed to get lavalink releases"); + if (!github) return console.error("Failed to get github releases"); + + if ((github.length < 1 || lavalink[0].tag_name !== github[0].tag_name) && !lavalink[0].draft && !lavalink[0].prerelease) { + console.log(`Release ${lavalink[0].tag_name} detected`); + + return await axios + .post( + `${process.env.GITHUB_API_URL}/repos/${process.env.GITHUB_REPOSITORY}/releases`, + { + tag_name: lavalink[0].tag_name, + name: lavalink[0].name, + body: `*This release was generated automatically.* [Click here to go to the lavalink release.](${lavalink[0].html_url})\n\n${lavalink[0].body}`, + }, + { + auth: { username: process.env.GITHUB_ACTOR, password: process.env.GITHUB_TOKEN }, + headers: { Accept: "application/vnd.github.v3+json", "User-Agent": "Node.js" }, + } + ) + .then((res) => console.log(`Release ${res.data.tag_name} created successfully. ${res.data.html_url}`)); + } else return console.log("Repository already up to date."); +} + +main(); diff --git a/package.json b/package.json new file mode 100644 index 0000000..f2c4dae --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "lavalink-arm64", + "version": "0.0.1", + "description": "Lavalink arm64 build", + "main": "index.js", + "scripts": { + "start": "node ." + }, + "repository": { + "type": "git", + "url": "git+https://github.com/DespenserTeam/Lavalink-arm64.git" + }, + "author": "despenser08 ", + "license": "MIT", + "bugs": { + "url": "https://github.com/DespenserTeam/Lavalink-arm64/issues" + }, + "homepage": "https://github.com/DespenserTeam/Lavalink-arm64#readme", + "dependencies": { + "axios": "^0.24.0" + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..87c872f --- /dev/null +++ b/yarn.lock @@ -0,0 +1,15 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +axios@^0.24.0: + version "0.24.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.24.0.tgz#804e6fa1e4b9c5288501dd9dff56a7a0940d20d6" + integrity sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA== + dependencies: + follow-redirects "^1.14.4" + +follow-redirects@^1.14.4: + version "1.14.5" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.5.tgz#f09a5848981d3c772b5392309778523f8d85c381" + integrity sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==