From c6c4d80c5c087ca12482a8260891eefcc7d586cb Mon Sep 17 00:00:00 2001 From: chirp <72366111+chirpxiv@users.noreply.github.com> Date: Sat, 28 Sep 2024 20:38:17 +0100 Subject: [PATCH] Upload workflows --- .github/FUNDING.yml | 2 + .github/release-notices.md | 2 + .github/workflows/release.yml | 97 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 64 +++++++++++++++++++++++ 4 files changed, 165 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/release-notices.md create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..bb238a7 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: chirpxiv +ko_fi: chirpxiv \ No newline at end of file diff --git a/.github/release-notices.md b/.github/release-notices.md new file mode 100644 index 0000000..4cba6b8 --- /dev/null +++ b/.github/release-notices.md @@ -0,0 +1,2 @@ +**Don't install GoodOmen by downloading this manually!** +See the README for instructions on plugin installation. \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8c14160 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,97 @@ +# Thanks to @Blooym and @Fayti1703 + +name: Release + +# Add a concurrency group incase a tag is created, deleted, and then recreated while a release is in progress. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# Only run this workflow when a tag is pushed when the tag starts with "v". +on: + push: + tags: + - 'v*' + +# So we can use the GitHub API to create releases with the run token. +permissions: + contents: write + +jobs: + Release: + if: github.event.pull_request.draft == false # Ignore draft PRs + runs-on: ubuntu-latest + defaults: + run: + working-directory: Pathfinder/ + shell: bash + env: + DALAMUD_HOME: /tmp/dalamud + IsCI: true + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + submodules: true # Grab any submodules that may be required + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + + - name: Download Dalamud Library + run: | + wget https://goatcorp.github.io/dalamud-distrib/latest.zip -O /tmp/dalamud.zip + unzip /tmp/dalamud.zip -d /tmp/dalamud + + - name: Restore Dependencies + run: dotnet restore + + - name: Build plugin in release mode + run: dotnet build -c Release --no-restore --nologo -o ./bin/Release + + - name: Generate Checksums + working-directory: Pathfinder/bin/Release/Pathfinder + run: | + sha512sum latest.zip >> checksums.sha512 + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: | + Pathfinder/bin/Release/Pathfinder/latest.zip + Pathfinder/bin/Release/Pathfinder/checksums.sha512 + prerelease: false # Releases cant be marked as prereleases as Dalamud wont be able to find them + append_body: true # Append the release notes to the release body + body_path: .github/release-notices.md # These notes are automatically added to the release body every time. + generate_release_notes: true # Automatically makes a release body from PRs since the last release. + fail_on_unmatched_files: true # If the files arent found, fail the workflow and abort the release. + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: Release Artifacts + path: | + Pathfinder/bin/Release/Pathfinder/latest.zip + Pathfinder/bin/Release/Pathfinder/checksums.sha512 + + - name: Update repo.json + run: | + cd ../ + + release_version=$(echo ${{ github.ref_name }} | sed 's/^v//') + repo_url=$(echo ${{ github.server_url }}/${{ github.repository }} | sed 's/#/\\#/g') + + sed -i repo.json -E \ + -e 's#"AssemblyVersion": "([0-9]*\.){2,3}[0-9]*"#"AssemblyVersion": "'"$release_version"'"#g' \ + -e 's#"TestingAssemblyVersion": "([0-9]*\.){2,3}[0-9]*"#"TestingAssemblyVersion": "'"$release_version"'"#' \ + -e 's#"DownloadLinkInstall": "[^"]*"#"DownloadLinkInstall": "'"$repo_url/releases/download/${{ github.ref_name }}/latest.zip"'"#g' \ + -e 's#"DownloadLinkTesting": "[^"]*"#"DownloadLinkTesting": "'"$repo_url/releases/download/${{ github.ref_name }}/latest.zip"'"#g' \ + -e 's#"DownloadLinkUpdate": "[^"]*"#"DownloadLinkUpdate": "'"$repo_url/releases/download/${{ github.ref_name }}/latest.zip"'"#g' + + git add repo.json + git config --local user.name "github-actions [bot]" + git config --local user.email "github-actions@users.noreply.github.com" + git commit -m "Update repo.json for ${{ github.ref_name }}" + + git push origin HEAD:main diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..90490f8 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,64 @@ +# Thanks to @Blooym and @Fayti1703 + +name: Tests + +# If another commit is made to the same pull request, the previous workflow run is cancelled to save resources. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +# Only run CI against the main branch or on PRs to the main branch. +on: + push: + branches: [main] + pull_request: + branches: [main] + types: [ready_for_review, opened, synchronize] + workflow_dispatch: + +jobs: + Build: + if: github.event.pull_request.draft == false # Ignore draft PRs + runs-on: ubuntu-latest + defaults: + run: + working-directory: Pathfinder/ + shell: bash + strategy: + matrix: + dotnet-version: [7.0.x] # Can add multiple .NET versions here to test against (For example, testing a new version of .NET before it's released) + dalamud-version: ["latest"] # Can add multiple Dalamud branches here to test against (For example, testing against Dalamud staging) + env: + DALAMUD_HOME: /tmp/dalamud + IsCI: true + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 # We don't need the history for testing builds, so we can save some time by not fetching it + submodules: true # Grab any submodules that may be required + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ matrix.dotnet-version }} + + - name: Download Dalamud Library + run: | + wget https://goatcorp.github.io/dalamud-distrib/${{ matrix.dalamud-version }}.zip -O /tmp/dalamud.zip + unzip /tmp/dalamud.zip -d /tmp/dalamud + + - name: Restore Dependencies + run: dotnet restore + + - name: Build plugin in debug mode + run: dotnet build -c Debug --no-restore --nologo + + - name: Build plugin in release mode + run: dotnet build -c Release --no-restore --nologo + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: Build Artifacts + path: Pathfinder/bin/