forked from mirrors/jellyfin-plugin-sso
66 lines
2.6 KiB
YAML
66 lines
2.6 KiB
YAML
name: release
|
|
|
|
on:
|
|
push:
|
|
tags: ["v[0-9]*"]
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: iuclabs-release
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
env:
|
|
VAULT_ADDR: https://vault.service.consul:8200
|
|
ARTIFACTAPI: https://artifactapi.k8s.syd1.au.unkin.net
|
|
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
|
|
DOTNET_NOLOGO: "1"
|
|
TAG: ${{ github.ref_name }}
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
|
|
with:
|
|
dotnet-version: 10.0.x
|
|
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
- name: build plugin
|
|
run: |
|
|
set -euo pipefail
|
|
version=$(sed -n 's/^version: *"\([0-9.]*\)".*/\1/p' build.yaml | head -1)
|
|
if [ "v${version}" != "${TAG}" ]; then
|
|
echo "::error::tag ${TAG} does not match build.yaml version ${version}; use make patch/minor/major/hotfix"
|
|
exit 1
|
|
fi
|
|
mkdir -p dist
|
|
uvx --from jprm==1.1.0 jprm plugin build . --output ./dist --version "${version}" --dotnet-configuration Release --dotnet-framework net10.0
|
|
sha256sum dist/*.zip
|
|
# login after the build: vault tokens live 15m
|
|
- uses: hashicorp/vault-action@892a26828f195e65540a40b4768ae4571f51ebfc # v4.0.0
|
|
with:
|
|
url: ${{ env.VAULT_ADDR }}
|
|
method: jwt
|
|
path: jwt/github/iuclabs
|
|
role: release
|
|
jwtGithubAudience: ${{ env.VAULT_ADDR }}
|
|
secrets: |
|
|
identity/oidc/token/artifactapi-writer token | ARTIFACTAPI_TOKEN
|
|
# uploads are immutable (409 on overwrite) and artifactapi has no HEAD route; an existing object is a no-op re-run
|
|
- name: publish
|
|
run: |
|
|
set -euo pipefail
|
|
zips=(dist/sso-authentication_*.zip)
|
|
zip="${zips[0]}"
|
|
url="${ARTIFACTAPI}/api/v2/remotes/jellyfin-plugins/files/unkin/jellyfin-plugin-sso/${TAG#v}/$(basename "${zip}")"
|
|
code=$(curl -s --cacert /etc/vault-ca/ca.crt -o /dev/null -w '%{http_code}' "${url}" || true)
|
|
if [ "${code}" = 200 ]; then
|
|
echo "${url} already published; skipping"
|
|
exit 0
|
|
fi
|
|
auth="${RUNNER_TEMP}/auth"
|
|
printf 'Authorization: Bearer %s\n' "${ARTIFACTAPI_TOKEN}" > "${auth}"
|
|
curl -fsS --cacert /etc/vault-ca/ca.crt -X PUT "${url}" \
|
|
-H "Content-Type: application/zip" -H @"${auth}" --data-binary @"${zip}"
|