Skip to content

Create release + SMP + package #7

Create release + SMP + package

Create release + SMP + package #7

Workflow file for this run

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:
# Check signing key
check-key:
name: 'Check key'
runs-on: ubuntu-latest
outputs:
exists: ${{ steps.key-check.outputs.exists }}
steps:
- name: Check for signing key availability
id: key-check
shell: bash
run: |
if [ "${{ secrets.GPG_PRIVATE_KEY }}" != '' ]; then
echo "exists=true" >> $GITHUB_OUTPUT;
else
echo "exists=false" >> $GITHUB_OUTPUT;
fi
- name: Result
run: echo "Key found:" ${{ steps.key-check.outputs.exists }}
# Bump version
update-version:
needs: [check-key]
name: 'Bump version'
runs-on: ubuntu-latest
outputs:
commit_hash: ${{ steps.commit-and-push.outputs.commit_hash }}
steps:
- uses: actions/[email protected]
- name: Write version to file
uses: "DamianReeves/write-file-action@master"
with:
path: VERSION
write-mode: overwrite
contents: v${{ inputs.tag }}
- name: Import GPG key
if: ${{ needs.check-key.outputs.exists == 'true' }}
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Commit & Push
id: commit-and-push
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Bump version by ${{ github.workflow}}
commit_user_email: ${{ github.actor }}@users.noreply.github.com
commit_user_name: ${{ github.actor }}
# Create new release + Tag
release:
needs: [update-version,check-key]
name: 'Create release'
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
ref: ${{ needs.update-version.outputs.commit_hash }}
- name: Import GPG key
if: ${{ needs.check-key.outputs.exists == 'true' }}
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Bump version and push tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN}}
custom_tag: ${{ inputs.tag }}
tag_prefix: 'v'
commit_sha: ${{ needs.update-version.outputs.commit_hash }}
- name: 'Create readme header'
shell: bash
working-directory: '.'
run: |
cp .github/RELEASE_HEAD.md RELEASE_HEAD.md
- name: 'Create release notes'
uses: CSchoel/[email protected]
with:
version: ${{ inputs.tag }}
- name: 'Create Release using GitHub CLI'
env:
# Expires every year, use bot as fallback
GITHUB_TOKEN: ${{ secrets.RELEASE_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/[email protected]
with:
files: 'foo_spider_monkey_panel-v1.6.1-mod.fb2k-component'
repo-token: ${{ secrets.RELEASE_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/[email protected]
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/[email protected]
if: ${{ steps.switch-case.outputs.match != '0' }}
with:
files: 'packages/*.zip'
repo-token: ${{ secrets.RELEASE_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'