From b2d98f49049133aa2a850f95e438a7bdc3cda60f Mon Sep 17 00:00:00 2001
From: Griefed <griefed@griefed.de>
Date: Sun, 1 Aug 2021 20:44:19 +0200
Subject: [PATCH] ci: GitHub workflows for documentation, release mirroring
 from GitLab upon tag push, greetings and sponsor labels for issues

---
 .github/workflows/gh-pages.yml       | 37 +++++++++++
 .github/workflows/github_release.yml | 96 ++++++++++++++++++++++++++++
 .github/workflows/greetings.yml      | 13 ++++
 .github/workflows/label_sponsors.yml | 16 +++++
 4 files changed, 162 insertions(+)
 create mode 100644 .github/workflows/gh-pages.yml
 create mode 100644 .github/workflows/github_release.yml
 create mode 100644 .github/workflows/greetings.yml
 create mode 100644 .github/workflows/label_sponsors.yml

diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml
new file mode 100644
index 0000000..b11e64f
--- /dev/null
+++ b/.github/workflows/gh-pages.yml
@@ -0,0 +1,37 @@
+name: Deploy javadocs to GitHub pages
+
+on:
+  push:
+    branches:
+      - main
+  workflow_dispatch:
+
+jobs:
+  pages:
+    runs-on: ubuntu-latest
+    steps:
+      # GET LATEST CODE
+      - name: Checkout latest code
+        uses: actions/checkout@master
+        with:
+          fetch-depth: 0
+
+      # BUILD PROJECT AND PUBLISH TO PACKAGES
+      - name: Set up JDK 8
+        uses: actions/setup-java@v2
+        with:
+          distribution: 'adopt'
+          java-version: '8'
+      - name: Grant execute permission for gradlew
+        run: chmod +x gradlew
+      - name: Build documentation
+        run: ./gradlew about build -x test
+      - name: List files
+        run: ls -ahl build/libs
+
+      # DEPLOY TO GH-PAGES
+      - name: Deploy to GitHub-Pages
+        uses: JamesIves/github-pages-deploy-action@4.1.4
+        with:
+          branch: gh-pages
+          folder: build/docs/javadoc
diff --git a/.github/workflows/github_release.yml b/.github/workflows/github_release.yml
new file mode 100644
index 0000000..dada9a5
--- /dev/null
+++ b/.github/workflows/github_release.yml
@@ -0,0 +1,96 @@
+name: Create GitHub Release after GitLab tag mirror
+
+on:
+  push:
+    tags:
+      - '*'
+
+jobs:
+  release:
+    runs-on: ubuntu-latest
+    steps:
+      # GET LATEST CODE
+      - name: Checkout latest code
+        uses: actions/checkout@master
+        with:
+          fetch-depth: 0
+
+      # EXTRACT TAG FROM PUSH
+      - name: Get tag
+        id: tag
+        uses: dawidd6/action-get-tag@v1
+      - name: Use tag
+        run: echo ${{steps.tag.outputs.tag}}
+
+      # GENERATE CHANGELOG, RELEASE
+      - id: conventional_changelog
+        uses: ardalanamini/auto-changelog@master
+        with:
+          token: ${{ secrets.GITHUB_TOKEN }}
+      - name: Create Release
+        id: create_release
+        uses: actions/create-release@latest
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          tag_name: ${{ github.ref }}
+          release_name: Release ${{steps.tag.outputs.tag}}
+          body: |
+            Automatic release of version: **${{steps.tag.outputs.tag}}**
+            **Changes in this release:**
+            ${{ steps.conventional_changelog.outputs.changelog }}
+          draft: false
+          prerelease: false
+
+      # BUILD PROJECT AND PUBLISH TO PACKAGES
+      - name: Set up JDK 8
+        uses: actions/setup-java@v2
+        with:
+          distribution: 'adopt'
+          java-version: '8'
+      - name: Grant execute permission for gradlew
+        run: chmod +x gradlew
+      - name: Publish to GitHub Packages
+        env:
+          GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          NEW_VERSION=$(echo "${{steps.tag.outputs.tag}}")
+          echo "New version: ${NEW_VERSION}"
+          echo "Github username: ${GITHUB_ACTOR}"
+          ./gradlew about
+          ./gradlew -Pversion=${NEW_VERSION} --info -x test
+      - name: List files
+        run: ls -ahl build/libs
+
+      # UPLOAD ASSETS TO RELEASE
+      - name: Upload Release Asset Main Jar
+        id: upload-release-asset
+        uses: actions/upload-release-asset@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          upload_url: ${{ steps.create_release.outputs.upload_url }}
+          asset_path: ./build/libs/serverpackcreatorexampleaddon-${{steps.tag.outputs.tag}}.jar
+          asset_name: serverpackcreatorexampleaddon-${{steps.tag.outputs.tag}}.jar
+          asset_content_type: application/jar
+      - name: Upload Release Asset Sources Jar
+        id: upload-release-asset-sources
+        uses: actions/upload-release-asset@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          upload_url: ${{ steps.create_release.outputs.upload_url }}
+          asset_path: ./build/libs/serverpackcreatorexampleaddon-${{steps.tag.outputs.tag}}-sources.jar
+          asset_name: serverpackcreatorexampleaddon-${{steps.tag.outputs.tag}}-sources.jar
+          asset_content_type: application/jar
+      - name: Upload Release Asset Javadoc Jar
+        id: upload-release-asset-javadoc
+        uses: actions/upload-release-asset@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          upload_url: ${{ steps.create_release.outputs.upload_url }}
+          asset_path: ./build/libs/serverpackcreatorexampleaddon-${{steps.tag.outputs.tag}}-javadoc.jar
+          asset_name: serverpackcreatorexampleaddon-${{steps.tag.outputs.tag}}-javadoc.jar
+          asset_content_type: application/jar
\ No newline at end of file
diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml
new file mode 100644
index 0000000..6b74e36
--- /dev/null
+++ b/.github/workflows/greetings.yml
@@ -0,0 +1,13 @@
+name: Greetings
+
+on: [pull_request, issues]
+
+jobs:
+  greeting:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/first-interaction@v1
+      with:
+        repo-token: ${{ secrets.GITHUB_TOKEN }}
+        issue-message: 'Thanks for opening your first issue here! Be sure to follow the [bug](https://github.com/Griefed/ServerPackCreator/blob/1bbbfc59207e801068aa0f92ccd2869079fce7da/.github/ISSUE_TEMPLATE/bug-report.md), [feature](https://github.com/Griefed/ServerPackCreator/blob/1bbbfc59207e801068aa0f92ccd2869079fce7da/.github/ISSUE_TEMPLATE/feature-request.md), or [documentation](https://github.com/Griefed/ServerPackCreator/blob/1bbbfc59207e801068aa0f92ccd2869079fce7da/.github/ISSUE_TEMPLATE/documentation-request.md) issue templates!'
+        pr-message: 'Thanks for opening this pull request! Be sure to follow the [pull request template](https://github.com/Griefed/ServerPackCreator/blob/1bbbfc59207e801068aa0f92ccd2869079fce7da/.github/ISSUE_TEMPLATE/pull_request.md)!'
diff --git a/.github/workflows/label_sponsors.yml b/.github/workflows/label_sponsors.yml
new file mode 100644
index 0000000..e545437
--- /dev/null
+++ b/.github/workflows/label_sponsors.yml
@@ -0,0 +1,16 @@
+name: Label sponsors
+
+on:
+  pull_request:
+    types: [opened]
+  issues:
+    types: [opened]
+
+jobs:
+  build:
+    name: Label issues and pull requests made by sponsors
+    runs-on: ubuntu-latest
+    steps:
+      - uses: JasonEtco/is-sponsor-label-action@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.CR_PAT }}
-- 
GitLab