Skip to content

Commit

Permalink
ci: use prerelease logic (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored May 22, 2024
1 parent 8e358fd commit 4cc0b57
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 14 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
branches: [master]
workflow_dispatch:

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
release:
name: Release
Expand All @@ -19,22 +23,21 @@ jobs:

- name: Setup Release
id: setup_release
uses: LizardByte/setup-release-action@v2024.511.154635
uses: LizardByte/setup-release-action@v2024.520.193857
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Create/Update GitHub Release
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/master') &&
steps.setup_release.outputs.publish_release == 'true'
uses: LizardByte/create-release-action@v2024.511.153520
uses: LizardByte/create-release-action@v2024.520.193838
with:
allowUpdates: true
artifacts: ""
body: ''
discussionCategory: announcements
generateReleaseNotes: true
name: ${{ steps.setup_release.outputs.release_tag }}
prerelease: ${{ steps.setup_release.outputs.publish_pre_release }}
prerelease: true
tag: ${{ steps.setup_release.outputs.release_tag }}
token: ${{ secrets.GH_BOT_TOKEN }}
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,33 @@ that can be used to publish your own plugins to your own gh-pages repository. Se
![Confirm Warning](/docs/images/jellyfin_confirm_third_party_plugin.png)
8. Select the `Catalog` tab to see the newly added plugins.
## Action
### Use in ci
```yml
jobs:
build:
runs-on: ubuntu-latest
steps:
# build your plugin
- name: Create/Update Jellyfin Release
uses: LizardByte/jellyfin-plugin-repo@master
with:
github_token: ${{ secrets.GH_BOT_TOKEN }}
committer_email: ${{ secrets.GH_BOT_EMAIL }}
committer_name: ${{ secrets.GH_BOT_NAME }}
release_tag: ${{ needs.setup_release.outputs.release_tag }}
zipfile: <path_to_your_zipfile>
```

### Use action on release events

LizardByte uses the following workflow for Jellyfin plugins.
This allows us to remove versions when we delete a release, as we only keep a single pre-release.

See [update-jellyfin-release.yml](https://github.com/LizardByte/Themerr-jellyfin/.github/workflows/update-jellyfin-release.yml)
for an example.
59 changes: 49 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: "Jellyfin manifest manager"
description: "Update a Jellyfin manifest file in a GitHub repository, and publish to gh-pages."
author: "LizardByte"
inputs:
action:
description: "The jprm action to perform. Choices are `add` or `remove`."
default: "add"
required: false
committer_email:
description: "The email address of the committer to the gh-pages branch."
required: true
Expand All @@ -29,11 +33,11 @@ inputs:
default: "LizardByte/jellyfin-plugin-repo"
required: false
plugin_url:
description: "The URL where the plugin zip file is (or will be) hosted. This will be evaluated if empty"
description: "The URL where the plugin zip file is (or will be) hosted. This will be evaluated if empty."
default: ""
required: false
zipfile:
description: "The path to the plugin zip file. This will be evaluated if empty"
description: "The path to the plugin zip file. This will be evaluated if empty."
default: ""
required: false

Expand All @@ -44,14 +48,38 @@ runs:
id: inputs
shell: bash
run: |
action=${{ inputs.action }}
branch=${{ inputs.branch }}
gh_pages_url=${{ inputs.gh_pages_url }}
repository=${{ inputs.repository }}
release_tag=${{ inputs.release_tag }}
# switch to ensure the action is valid
case $action in
add)
;;
remove)
;;
*)
echo ":error: Invalid action: $action"
echo "Valid actions are 'add' or 'remove'"
exit 1
;;
esac
# the repository running this action
source_repository=${{ github.event.repository.name }}
if [[ "${{ github.event.repository }} =~ ^LizardByte/ ]]; then
# strip `-jellyfin` from the end of the name, if in the LizardByte org
plugin_name=$(echo $source_repository | sed 's/-jellyfin$//' | tr '[:upper:]' '[:lower:]')
else
plugin_name=$(echo $source_repository | tr '[:upper:]' '[:lower:]')
fi
# release version, tag without v prefix
release_version=$(echo $release_tag | sed 's/^v//')
if [ -z "${{ inputs.zipfile }}" ]; then
# repository name in lowercase
repository_name=$(echo ${source_repository} | tr '[:upper:]' '[:lower:]')
Expand All @@ -68,10 +96,12 @@ runs:
plugin_url=${{ inputs.plugin_url }}
fi
echo "action=${action}" >> $GITHUB_OUTPUT
echo "branch=${branch}" >> $GITHUB_OUTPUT
echo "gh_pages_url=${gh_pages_url}" >> $GITHUB_OUTPUT
echo "repository=${repository}" >> $GITHUB_OUTPUT
echo "release_tag=${release_tag}" >> $GITHUB_OUTPUT
echo "release_version=${release_version}" >> $GITHUB_OUTPUT
echo "source_repository=${source_repository}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -102,7 +132,7 @@ runs:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
fetch-depth: 0 # otherwise, will fail to push refs to dest repo

- name: JPRM repo init/add
- name: JPRM repo
shell: bash
run: |
# initialize repo if it doesn't exist
Expand All @@ -112,13 +142,22 @@ runs:
${{ steps.inputs.outputs.branch }} || true # ignore error if already exists
# add plugin to repo
${{ steps.setup-python.outputs.python-path }} \
-m jprm \
repo add \
--url ${{ steps.inputs.outputs.gh_pages_url }} \
--plugin-url ${{ steps.inputs.outputs.plugin_url }} \
${{ steps.inputs.outputs.branch }} \
${{ steps.inputs.outputs.zipfile_path }}
if [ "${{ steps.inputs.outputs.action }}" == "add" ]; then
${{ steps.setup-python.outputs.python-path }} \
-m jprm \
repo add \
--url ${{ steps.inputs.outputs.gh_pages_url }} \
--plugin-url ${{ steps.inputs.outputs.plugin_url }} \
${{ steps.inputs.outputs.branch }} \
${{ steps.inputs.outputs.zipfile_path }}
elif [ "${{ steps.inputs.outputs.action }}" == "remove" ]; then
${{ steps.setup-python.outputs.python-path }} \
-m jprm \
repo remove \
${{ steps.inputs.outputs.branch }} \
${{ steps.inputs.outputs.plugin_name }} \
${{ steps.inputs.outputs.release_version }}
fi
- name: Publish gh-pages
uses: actions-js/[email protected]
Expand Down

0 comments on commit 4cc0b57

Please sign in to comment.