Release #629
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- "*-?v[0-9]+*" | |
env: | |
GHCR_REGISTRY: ghcr.io | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create or update release | |
uses: actions/github-script@v7 | |
env: | |
TAG_NAME: ${{ github.ref_name }} | |
with: | |
script: | | |
const tag = process.env.TAG_NAME || github.ref_name; | |
const repo = context.repo; | |
const majorVersion = tag.match(/v(\d+)\.\d+\.\d+/)[1]; | |
const releaseName = `Version ${majorVersion}`; | |
const date = new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); | |
const dynamicBody = `<!-- DYNAMIC START -->\n*Created from tag*: \`${tag}\`\n*Created from git revision*: \`${context.sha}\`\n*Published on*: \`${date}\`\n<!-- DYNAMIC END -->`; | |
async function findOrCreateRelease() { | |
const { data: releases } = await github.rest.repos.listReleases(repo); | |
let existingRelease = releases.find(release => release.name === releaseName); | |
if (existingRelease) { | |
const existingBody = existingRelease.body; | |
const newBody = existingBody.replace(/<!-- DYNAMIC START -->[^]*<!-- DYNAMIC END -->/, dynamicBody); | |
await github.rest.repos.updateRelease({ | |
...repo, | |
release_id: existingRelease.id, | |
tag_name: tag, | |
body: newBody, | |
draft: false, | |
}); | |
console.log("Release updated to associate with new tag."); | |
} else { | |
const fullBody = `${dynamicBody}\n\n## Release Notes\n\n- Some bug fixes.`; | |
await github.rest.repos.createRelease({ | |
...repo, | |
tag_name: tag, | |
name: releaseName, | |
body: fullBody, | |
draft: false, | |
prerelease: false | |
}); | |
console.log("Release created successfully."); | |
} | |
} | |
findOrCreateRelease(); | |
docker-release: | |
runs-on: ubuntu-latest | |
needs: create-release | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the ghcr container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.GHCR_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Log in to the docker hub container registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Get docker image names | |
id: required_args | |
uses: actions/github-script@v7 | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
with: | |
script: | | |
const repoName = context.payload.repository.name; | |
const refName = context.ref.replace('refs/tags/', ''); | |
core.setOutput('APP_VERSION', refName); | |
const dockerHubActor = process.env.DOCKER_USERNAME; | |
const ghcrRegistry = process.env.GHCR_REGISTRY; | |
const ghcrActor = context.actor; | |
function generateVersionArray(version) { | |
const parts = version.split("."); | |
const versionArray = []; | |
for (let i = 0; i < parts.length; i++) | |
versionArray.push(parts.slice(0, i + 1).join(".")); | |
versionArray.push("latest"); | |
return versionArray; | |
} | |
const versionTags = generateVersionArray(refName); | |
const ghcrImageName = `${ghcrRegistry}/${ghcrActor}/${repoName}`; | |
const ghcrTags = versionTags.map((tag) => `${ghcrImageName}:${tag}`); | |
const dockerHubImageName = `${dockerHubActor}/${repoName}`; | |
const dockerHubTags = versionTags.map((tag) => `${dockerHubImageName}:${tag}`); | |
const imageNames = [...ghcrTags, dockerHubTags].join(",").toLowerCase(); | |
core.setOutput('image_names', imageNames); | |
- name: Build and push to ghcr | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.required_args.outputs.image_names }} | |
build-args: | | |
APP_VERSION=${{ steps.required_args.outputs.APP_VERSION }} | |
DEFAULT_TMDB_ACCESS_TOKEN=${{ secrets.DEFAULT_TMDB_ACCESS_TOKEN }} | |
DEFAULT_MAL_CLIENT_ID=${{ secrets.DEFAULT_MAL_CLIENT_ID }} | |
upload-kodi-plugin: | |
runs-on: ubuntu-20.04 | |
needs: docker-release | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Moon | |
uses: moonrepo/setup-toolchain@v0 | |
with: | |
auto-install: true | |
- name: Build plugin | |
run: moon run kodi:build | |
- name: Upload plugin to releases | |
run: gh release upload --clobber ${{ github.ref_name }} "tmp/script.ryot.zip" | |
deploy-demo-instance: | |
runs-on: ubuntu-latest | |
needs: docker-release | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up CLI | |
uses: superfly/flyctl-actions/setup-flyctl@master | |
- name: Deploy | |
run: flyctl deploy --remote-only --detach --config ci/fly.toml | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
deploy-docs: | |
runs-on: ubuntu-latest | |
needs: docker-release | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install poetry | |
uses: abatilo/actions-poetry@v2 | |
- name: Install dependencies | |
run: cd docs && poetry install | |
- name: Build docs | |
run: cd docs && poetry run mkdocs build | |
- name: Push to deployment branch | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: docs/site | |
publish_branch: nf-docs | |
force_orphan: true |