From 7efdbad98aeee5486042cc6f17b53da9691b9d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lillie=E2=84=A2?= <66176496+lilliepad1@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:21:06 -0400 Subject: [PATCH] Implement #1579 https://github.com/jagrosh/MusicBot/pull/1579 --- .github/workflows/build-and-test-old.yml | 22 ++++++++ .github/workflows/build-and-test.yml | 43 ++++++++++++--- .github/workflows/make-release-old.yml | 70 ++++++++++++++++++++++++ .github/workflows/make-release.yml | 59 ++++++++------------ 4 files changed, 149 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/build-and-test-old.yml create mode 100644 .github/workflows/make-release-old.yml diff --git a/.github/workflows/build-and-test-old.yml b/.github/workflows/build-and-test-old.yml new file mode 100644 index 000000000..f5b4631e7 --- /dev/null +++ b/.github/workflows/build-and-test-old.yml @@ -0,0 +1,22 @@ +name: Build and Test +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + cache: maven + - name: Build and Test with Maven + run: mvn --batch-mode --update-snapshots verify diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index f5b4631e7..9f29d8a4a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,22 +1,47 @@ name: Build and Test on: push: - branches: - - master + paths-ignore: + - '.github/workflows/make-release.yml' + - '.github/ISSUE_TEMPLATE/**' + - '.github/*.md' + - '.github/FUNDING.yml' + - '.circleci/**' + - 'LICENSE' + - 'CNAME' + - 'README.md' + branches: [ master ] pull_request: - branches: - - master + branches: [ master ] jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 with: java-version: '11' - distribution: 'adopt' + distribution: 'temurin' cache: maven - - name: Build and Test with Maven + + - name: Build with Maven run: mvn --batch-mode --update-snapshots verify + + - name: Set environments + run: | + { + echo "commit=$(echo ${{ github.sha }} | cut -c-7)" + echo "repo=$(echo ${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/})" + } >> $GITHUB_ENV + + - name: Upload JAR + uses: actions/upload-artifact@v4 + with: + name: ${{ env.repo }}@${{ env.commit }} + path: target/JMusicBot-Snapshot-All.jar + if-no-files-found: error diff --git a/.github/workflows/make-release-old.yml b/.github/workflows/make-release-old.yml new file mode 100644 index 000000000..ce1f58be9 --- /dev/null +++ b/.github/workflows/make-release-old.yml @@ -0,0 +1,70 @@ +name: Make Release +on: + workflow_dispatch: + inputs: + version_number: + description: 'Version Number' + required: true + type: string + info: + description: 'Description of this Release' + required: true + type: string + +jobs: + build_jar: + name: Build Jar + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + cache: maven + - name: Set Version + uses: datamonsters/replace-action@v2 + with: + files: 'pom.xml' + replacements: 'Snapshot=${{ github.event.inputs.version_number }}' + - name: Build with Maven + run: mvn --batch-mode --update-snapshots verify + - name: Rename jar + run: mv target/*-All.jar JMusicBot-${{ github.event.inputs.version_number }}.jar + - name: Upload jar + uses: actions/upload-artifact@v3 + with: + name: jar + path: JMusicBot-${{ github.event.inputs.version_number }}.jar + if-no-files-found: error + create_release: + name: Create Release + runs-on: ubuntu-latest + needs: build_jar + steps: + - name: Download a Build Artifact + uses: actions/download-artifact@v3.0.0 + with: + name: jar + path: . + - name: Show Artifacts + run: ls -R + - name: Create Release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.event.inputs.version_number }} + name: Version ${{ github.event.inputs.version_number }} + draft: true + prerelease: false + artifacts: "*.jar" + body: | + ${{ github.event.inputs.info }} + + --- + ### Setup + https://jmusicbot.com/setup + https://jmusicbot.com/config + # Download: [JMusicBot-${{ github.event.inputs.version_number }}.jar](https://github.com/jagrosh/MusicBot/releases/download/${{ github.event.inputs.version_number }}/JMusicBot-${{ github.event.inputs.version_number }}.jar) diff --git a/.github/workflows/make-release.yml b/.github/workflows/make-release.yml index ce1f58be9..1dd6561c8 100644 --- a/.github/workflows/make-release.yml +++ b/.github/workflows/make-release.yml @@ -8,58 +8,45 @@ on: type: string info: description: 'Description of this Release' - required: true + required: false type: string jobs: - build_jar: - name: Build Jar + build: + name: Build JAR runs-on: ubuntu-latest steps: + - name: Checkout - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 with: java-version: '11' - distribution: 'adopt' + distribution: 'temurin' cache: maven + - name: Set Version - uses: datamonsters/replace-action@v2 - with: - files: 'pom.xml' - replacements: 'Snapshot=${{ github.event.inputs.version_number }}' + run: sed -e 's/Snapshot/${{ github.event.inputs.version_number }}/' -i pom.xml + - name: Build with Maven run: mvn --batch-mode --update-snapshots verify - - name: Rename jar - run: mv target/*-All.jar JMusicBot-${{ github.event.inputs.version_number }}.jar - - name: Upload jar - uses: actions/upload-artifact@v3 - with: - name: jar - path: JMusicBot-${{ github.event.inputs.version_number }}.jar - if-no-files-found: error - create_release: - name: Create Release - runs-on: ubuntu-latest - needs: build_jar - steps: - - name: Download a Build Artifact - uses: actions/download-artifact@v3.0.0 - with: - name: jar - path: . - - name: Show Artifacts - run: ls -R + + - name: Set environments + run: echo "repo=$(echo ${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/})" >> $GITHUB_ENV + + - name: Rename JAR + run: mv target/JMusicBot-${{ github.event.inputs.version_number }}-All.jar JMusicBot-${{ github.event.inputs.version_number }}.jar + - name: Create Release - uses: ncipollo/release-action@v1 + uses: softprops/action-gh-release@v2 with: - token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ github.event.inputs.version_number }} + tag_name: ${{ github.event.inputs.version_number }} name: Version ${{ github.event.inputs.version_number }} draft: true prerelease: false - artifacts: "*.jar" + files: JMusicBot-${{ github.event.inputs.version_number }}.jar body: | ${{ github.event.inputs.info }} @@ -67,4 +54,4 @@ jobs: ### Setup https://jmusicbot.com/setup https://jmusicbot.com/config - # Download: [JMusicBot-${{ github.event.inputs.version_number }}.jar](https://github.com/jagrosh/MusicBot/releases/download/${{ github.event.inputs.version_number }}/JMusicBot-${{ github.event.inputs.version_number }}.jar) + # Download: [JMusicBot-${{ github.event.inputs.version_number }}.jar](https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.version_number }}/JMusicBot-${{ github.event.inputs.version_number }}.jar)