Skip to content

Fix release workflow #22

Fix release workflow

Fix release workflow #22

Workflow file for this run

name: Release
on:
push:
tags: ['*']
jobs:
release:
name: "Create release"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
- name: "Verify release version"
run: >-
grep -q "__version__ = '${GITHUB_REF_NAME#v}'" MangAdventure/__init__.py &&
grep -q "@${GITHUB_REF_NAME}#egg=mangadventure\"" docs/install.rst &&
grep -q "@${GITHUB_REF_NAME}#egg=mangadventure\[" docs/install.rst &&
grep -q "^${GITHUB_REF_NAME}$" docs/changelog.rst
- name: "Mark previous prerelease"
continue-on-error: true
run: |-
tag="$(gh release view --json tagName -t '{{.tagName}}')"
# skip if the new tag has a different minor version
[[ ${GITHUB_REF_NAME%.*} == ${tag%.*} ]] || exit 0
gh release edit "$tag" --prerelease
curl -Ssf -XPATCH -d 'active=false' -H "Authorization: Token $RTFD_TOKEN" \
"https://readthedocs.org/api/v3/projects/mangadventure/versions/$tag/"
env:
RTFD_TOKEN: ${{secrets.RTFD_TOKEN}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: "Parse release body"
run: make changes > changes.md
working-directory: docs
- name: "Upload release"
run: gh release create -F docs/changes.md --generate-notes $GITHUB_REF_NAME
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: "Send data to Discord"
run: |-
jq --arg name "${GITHUB_REPOSITORY#*/}" \
--arg author_url "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY_OWNER" \
--arg icon_url "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY_OWNER.png?s=40" \
--arg title "New release published: $GITHUB_REF_NAME" \
--arg url "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/$GITHUB_REF_NAME" \
--arg description "$(<docs/changes.md)" \
-Mn '{
username: "GitHub",
avatar_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
embeds: [{author: {$name, $icon_url, url: $author_url}, $url, $title, $description}]
}' | curl "$RELEASE_WEBHOOK" -H 'Content-Type: application/json' \
-Ssf -d@- -A "GitHub-Actions ($GITHUB_REPOSITORY, v0.1.1)"
env:
RELEASE_WEBHOOK: ${{secrets.RELEASE_WEBHOOK}}
docker:
name: "Build Docker image"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
- name: "Log in to the Container registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v3
- name: "Extract metadata for Docker"
uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/mangadventure/app
- name: "Build and push Docker image"
uses: docker/build-push-action@v5
with:
context: .
push: true
file: docker/Dockerfile
tags: ${{steps.meta.outputs.tags}}
labels: ${{steps.meta.outputs.labels}}