From ac8bbce286735415084ca0396577bc0edeac27a5 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 12 Dec 2021 21:48:15 +0100 Subject: [PATCH] Add release pipeline --- .github/workflows/release.yml | 77 +++++++++++++++++++++++++++++++++++ build.gradle | 18 ++++++++ 2 files changed, 95 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..d691fb565 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,77 @@ +name: Release +on: + push: + tags: + - "v**" +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Get tag name + uses: olegtarasov/get-tag@v2.1 + id: tagName + - name: Validate semver + run: | + echo $GIT_TAG_NAME | grep -oP '^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$' + - name: Checkout repository + uses: actions/checkout@v2 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Setup JDK 17 + uses: actions/setup-java@v1 + with: + java-version: 17 + - name: Make Gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: Build + run: ./gradlew build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE: ${{ steps.tagName.outputs.tag }} + - name: Build documentation + run: ./gradlew javadoc + env: + RELEASE: ${{ steps.tagName.outputs.tag }} + - name: Publish documentation + uses: JamesIves/github-pages-deploy-action@4.1.5 + with: + branch: gh-pages + folder: build/docs/javadoc + - name: Publish + run: ./gradlew publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE: ${{ steps.tagName.outputs.tag }} + - name: Retrieve changelog + id: changelog_reader + uses: mindsers/changelog-reader-action@v2 + with: + version: 'Unreleased' + path: ./CHANGELOG.md + - name: Release on GitHub + uses: softprops/action-gh-release@v1 + id: ghRelease + with: + body: ${{ steps.changelog_reader.outputs.changes }} + name: ${{ steps.tagName.outputs.tag }} + files: | + build/libs/*.jar + # This is necessary because the Discord action doesn't support GH actions variable expansion? + - name: Set release URL + run: | + echo "RELEASE_URL=${{ steps.ghRelease.outputs.url }}" >> $GITHUB_ENV + - name: Notify Discord + uses: Ilshidur/action-discord@0.3.2 + with: + args: 'Refined Storage {{ GIT_TAG_NAME }} has been released! {{ RELEASE_URL }}' + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + - name: Notify Twitter + uses: ethomson/send-tweet-action@v1 + with: + status: Refined Storage ${{ env.GIT_TAG_NAME }} has been released! ${{ env.RELEASE_URL }} + consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }} + consumer-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} + access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }} + access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} diff --git a/build.gradle b/build.gradle index 84fef0f9b..60239e941 100755 --- a/build.gradle +++ b/build.gradle @@ -126,3 +126,21 @@ jar { } jar.finalizedBy('reobfJar') + +publishing { + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/refinedmods/refinedstorage") + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + } + publications { + gpr(MavenPublication) { + from(components.java) + } + } +}