fix
This commit is contained in:
76
.github/workflows/release.yml
vendored
76
.github/workflows/release.yml
vendored
@@ -7,6 +7,11 @@ on:
|
||||
- "rc*"
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_tag:
|
||||
description: "Existing tag to publish, for example draft2026, rc2026, or v2026"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -14,6 +19,7 @@ permissions:
|
||||
env:
|
||||
MKDOCS_CONFIG: mkdocs/mkdocs.yml
|
||||
MKDOCS_STRICT: ${{ vars.MKDOCS_STRICT || 'true' }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag || github.ref_name }}
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
@@ -24,6 +30,26 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ inputs.release_tag || github.ref }}
|
||||
|
||||
- name: Validate release tag
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
case "${RELEASE_TAG}" in
|
||||
draft*|rc*|v*) ;;
|
||||
*)
|
||||
echo "::error::Release tag must start with draft, rc, or v. Got '${RELEASE_TAG}'."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if ! git rev-parse --verify --quiet "refs/tags/${RELEASE_TAG}" >/dev/null; then
|
||||
echo "::error::Tag '${RELEASE_TAG}' was not found. Create and push the tag before running this workflow."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "RELEASE_COMMIT=$(git rev-list -n 1 "${RELEASE_TAG}")" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
@@ -46,12 +72,12 @@ jobs:
|
||||
|
||||
REPO_SLUG="${GITHUB_REPOSITORY#*/}"
|
||||
BASE_SITE_URL="https://${GITHUB_REPOSITORY_OWNER}.github.io/${REPO_SLUG}/"
|
||||
MKDOCS_REPO_URL="https://github.com/${GITHUB_REPOSITORY}/tree/${GITHUB_REF_NAME}"
|
||||
MKDOCS_REPO_URL="https://github.com/${GITHUB_REPOSITORY}/tree/${RELEASE_TAG}"
|
||||
MKDOCS_REPO_NAME="${GITHUB_REPOSITORY}"
|
||||
|
||||
if [[ "${GITHUB_REF_NAME}" == draft* ]]; then
|
||||
if [[ "${RELEASE_TAG}" == draft* ]]; then
|
||||
MKDOCS_SITE_URL="${BASE_SITE_URL}draft/"
|
||||
elif [[ "${GITHUB_REF_NAME}" == rc* ]]; then
|
||||
elif [[ "${RELEASE_TAG}" == rc* ]]; then
|
||||
MKDOCS_SITE_URL="${BASE_SITE_URL}rc/"
|
||||
else
|
||||
MKDOCS_SITE_URL="${BASE_SITE_URL}"
|
||||
@@ -66,7 +92,7 @@ jobs:
|
||||
|
||||
OUT_BASE="${RUNNER_TEMP}/mkdocs_out"
|
||||
SITE="${OUT_BASE}/site"
|
||||
SITE_OFFLINE="${OUT_BASE}/site_offline/${GITHUB_REF_NAME}"
|
||||
SITE_OFFLINE="${OUT_BASE}/site_offline/${RELEASE_TAG}"
|
||||
|
||||
rm -rf "${OUT_BASE}"
|
||||
mkdir -p "${SITE}" "${SITE_OFFLINE}"
|
||||
@@ -81,7 +107,7 @@ jobs:
|
||||
SHORT_SHA="${GITHUB_SHA::7}"
|
||||
|
||||
OUT_DIR="${RUNNER_TEMP}/pandoc"
|
||||
OUT_FILE="${GITHUB_REF_NAME}-${SHORT_SHA}.docx"
|
||||
OUT_FILE="${RELEASE_TAG}-${SHORT_SHA}.docx"
|
||||
echo "SHORT_SHA=`echo ${SHORT_SHA}`" >> $GITHUB_ENV
|
||||
|
||||
mkdir -p "${OUT_DIR}"
|
||||
@@ -108,7 +134,7 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${RUNNER_TEMP}/mkdocs_out/site_offline/"
|
||||
zip -r "${GITHUB_REF_NAME}.zip" ./${GITHUB_REF_NAME}
|
||||
zip -r "${RELEASE_TAG}.zip" ./${RELEASE_TAG}
|
||||
|
||||
- name: Prepare release notes
|
||||
run: |
|
||||
@@ -116,7 +142,7 @@ jobs:
|
||||
|
||||
RELEASE_NOTES="${RUNNER_TEMP}/release-notes.md"
|
||||
|
||||
if [[ "${GITHUB_REF_NAME}" == draft* || "${GITHUB_REF_NAME}" == rc* ]]; then
|
||||
if [[ "${RELEASE_TAG}" == draft* || "${RELEASE_TAG}" == rc* ]]; then
|
||||
printf 'Prerelease.\n\n' > "${RELEASE_NOTES}"
|
||||
else
|
||||
: > "${RELEASE_NOTES}"
|
||||
@@ -125,27 +151,31 @@ jobs:
|
||||
cat docs/summary-of-changes.md >> "${RELEASE_NOTES}"
|
||||
|
||||
- name: Publish prerelease
|
||||
if: startsWith(github.ref_name, 'rc') || startsWith(github.ref_name, 'draft')
|
||||
if: startsWith(env.RELEASE_TAG, 'rc') || startsWith(env.RELEASE_TAG, 'draft')
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
allowUpdates: true
|
||||
artifacts: ${{ runner.temp }}/mkdocs_out/site_offline/${{ github.ref_name }}.zip,${{ runner.temp }}/pandoc/${{ github.ref_name }}-${{ env.SHORT_SHA }}.docx
|
||||
artifacts: ${{ runner.temp }}/mkdocs_out/site_offline/${{ env.RELEASE_TAG }}.zip,${{ runner.temp }}/pandoc/${{ env.RELEASE_TAG }}-${{ env.SHORT_SHA }}.docx
|
||||
bodyFile: ${{ runner.temp }}/release-notes.md
|
||||
name: ${{ github.ref_name }}
|
||||
commit: ${{ env.RELEASE_COMMIT }}
|
||||
name: ${{ env.RELEASE_TAG }}
|
||||
prerelease: true
|
||||
replacesArtifacts: true
|
||||
tag: ${{ github.ref_name }}
|
||||
tag: ${{ env.RELEASE_TAG }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Publish release
|
||||
if: startsWith(github.ref_name, 'v')
|
||||
if: startsWith(env.RELEASE_TAG, 'v')
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
allowUpdates: true
|
||||
artifacts: ${{ runner.temp }}/mkdocs_out/site_offline/${{ github.ref_name }}.zip,${{ runner.temp }}/pandoc/${{ github.ref_name }}-${{ env.SHORT_SHA }}.docx
|
||||
artifacts: ${{ runner.temp }}/mkdocs_out/site_offline/${{ env.RELEASE_TAG }}.zip,${{ runner.temp }}/pandoc/${{ env.RELEASE_TAG }}-${{ env.SHORT_SHA }}.docx
|
||||
bodyFile: ${{ runner.temp }}/release-notes.md
|
||||
name: ${{ github.ref_name }}
|
||||
commit: ${{ env.RELEASE_COMMIT }}
|
||||
name: ${{ env.RELEASE_TAG }}
|
||||
replacesArtifacts: true
|
||||
tag: ${{ github.ref_name }}
|
||||
tag: ${{ env.RELEASE_TAG }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Checkout gh-pages branch
|
||||
uses: actions/checkout@v4
|
||||
@@ -154,7 +184,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Deploy release to gh-pages root
|
||||
if: startsWith(github.ref_name, 'v')
|
||||
if: startsWith(env.RELEASE_TAG, 'v')
|
||||
run: |
|
||||
set -euo pipefail
|
||||
rm -rf ./*
|
||||
@@ -162,35 +192,35 @@ jobs:
|
||||
git add -A
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git commit -m "Deploy release ${GITHUB_REF_NAME}" || echo "No changes to commit"
|
||||
git commit -m "Deploy release ${RELEASE_TAG}" || echo "No changes to commit"
|
||||
git push origin gh-pages
|
||||
|
||||
- name: Deploy RC preview to /rc/
|
||||
if: startsWith(github.ref_name, 'rc')
|
||||
if: startsWith(env.RELEASE_TAG, 'rc')
|
||||
run: |
|
||||
set -euo pipefail
|
||||
rm -rf rc draft
|
||||
mkdir -p rc
|
||||
cp -a ${RUNNER_TEMP}/mkdocs_out/site/. rc/
|
||||
printf '{"tag":"%s"}\n' "${GITHUB_REF_NAME}" > rc/rc.json
|
||||
printf '{"tag":"%s"}\n' "${RELEASE_TAG}" > rc/rc.json
|
||||
|
||||
git add -A
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git commit -m "Deploy RC preview ${GITHUB_REF_NAME}" || echo "No changes to commit"
|
||||
git commit -m "Deploy RC preview ${RELEASE_TAG}" || echo "No changes to commit"
|
||||
git push origin gh-pages
|
||||
|
||||
- name: Deploy draft preview to /draft/
|
||||
if: startsWith(github.ref_name, 'draft')
|
||||
if: startsWith(env.RELEASE_TAG, 'draft')
|
||||
run: |
|
||||
set -euo pipefail
|
||||
rm -rf rc draft
|
||||
mkdir -p draft
|
||||
cp -a ${RUNNER_TEMP}/mkdocs_out/site/. draft/
|
||||
printf '{"tag":"%s"}\n' "${GITHUB_REF_NAME}" > draft/draft.json
|
||||
printf '{"tag":"%s"}\n' "${RELEASE_TAG}" > draft/draft.json
|
||||
|
||||
git add -A
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git commit -m "Deploy draft preview ${GITHUB_REF_NAME}" || echo "No changes to commit"
|
||||
git commit -m "Deploy draft preview ${RELEASE_TAG}" || echo "No changes to commit"
|
||||
git push origin gh-pages
|
||||
|
||||
Reference in New Issue
Block a user