From 664a2a3b7f9c9f85434048945d49495fc1be2f3f Mon Sep 17 00:00:00 2001 From: regorxxx Date: Sat, 9 Dec 2023 00:09:49 +0100 Subject: [PATCH] Automate actions. --- .github/RELEASE_HEAD.md | 4 ++ .github/workflows/clean.yml | 20 ++++++++ .github/workflows/release.yml | 95 +++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 .github/RELEASE_HEAD.md create mode 100644 .github/workflows/clean.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/RELEASE_HEAD.md b/.github/RELEASE_HEAD.md new file mode 100644 index 0000000..fd67f1f --- /dev/null +++ b/.github/RELEASE_HEAD.md @@ -0,0 +1,4 @@ +**There may be a SMP's bug on installation. See wiki. +REQUIRES SMP 1.6.1 (mod version attached has some improvements by [marc23](https://hydrogenaud.io/index.php/topic,116669.msg1026243.html#msg1026243))** + +See full [changelog here](https://github.com/regorxxx/ListenBrainz-SMP/blob/main/CHANGELOG.md). \ No newline at end of file diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 0000000..9c0d945 --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,20 @@ +name: Clean workflow runs (automatic) +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + # Run daily, at 00:00 + +jobs: + delete: + runs-on: ubuntu-latest + permissions: + actions: write + steps: + - name: Delete workflow runs + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ github.token }} + repository: ${{ github.repository }} + retain_days: 0 + keep_minimum_runs: 1 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ff29c22 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,95 @@ +name: Create release + SMP + package + +on: + workflow_dispatch: + inputs: + tag: + description: 'Release tag: (X.X.X)' + required: true + type: string + title: + description: 'Release title:' + required: false + type: string + +jobs: + # Create new release + Tag + release: + name: 'Create release' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4.1.1 + - name: Bump version and push tag + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + custom_tag: ${{ inputs.tag }} + tag_prefix: 'v' + - name: 'Create readme header' + shell: bash + working-directory: '.' + run: | + cp .github/RELEASE_HEAD.md RELEASE_HEAD.md + - name: 'Create release notes' + uses: CSchoel/release-notes-from-changelog@v1.3.0 + with: + version: ${{ inputs.tag }} + - name: 'Create Release using GitHub CLI' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: > + gh release create + --verify-tag + --latest + -F RELEASE.md + -t 'v${{ inputs.tag }} - ${{ inputs.title }}' + 'v${{ inputs.tag }}' + # Attach assets + mod: + needs: release + name: 'Attach SMP mod' + runs-on: ubuntu-latest + + steps: + - name: 'Get binaries' + run: | + curl -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \ + -H 'Accept: application/vnd.github.v4.raw' \ + -O \ + -L https://api.github.com/repos/regorxxx/foobar2000-assets/contents/Spider%20Monkey%20Panel/foo_spider_monkey_panel-v1.6.1-mod.fb2k-component + - uses: AButler/upload-release-assets@v3.0 + with: + files: 'foo_spider_monkey_panel-v1.6.1-mod.fb2k-component' + repo-token: ${{ secrets.GITHUB_TOKEN }} + release-tag: 'v${{ inputs.tag }}' + # Build and attach package + package: + needs: release + name: 'Attach Package' + runs-on: windows-latest + + steps: + - uses: thaitype/actions-switch-case@v1 + id: switch-case + with: + default: '0' + conditionals-with-values: | + ${{ 'World-Map-SMP' == github.event.repository.name }} => '1' + ${{ 'Playlist-Manager-SMP' == github.event.repository.name }} => '2' + ${{ 'Not-a-Waveform-Seekbar-SMP' == github.event.repository.name }} => '3' + ${{ 'Timeline-SMP' == github.event.repository.name }} => '4' + - uses: actions/checkout@v4.1.1 + if: ${{ steps.switch-case.outputs.match != '0' }} + - name: 'Create package' + if: ${{ steps.switch-case.outputs.match != '0'}} + run: ./_createPackage.bat ${{ steps.switch-case.outputs.match }} + - uses: AButler/upload-release-assets@v3.0 + if: ${{ steps.switch-case.outputs.match != '0' }} + with: + files: 'packages/*.zip' + repo-token: ${{ secrets.GITHUB_TOKEN }} + release-tag: 'v${{ inputs.tag }}' + - name: 'No package associated to repository' + if: ${{ steps.switch-case.outputs.match == '0' }} + run: echo 'No package associated'