152 lines
6.1 KiB
YAML
152 lines
6.1 KiB
YAML
name: Release LinkLog
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
IMAGE_NAME: git.kolkman.org/olaf/link-log
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out release tag
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Validate versions and signed XPI
|
|
id: release
|
|
run: |
|
|
python3 scripts/release/validate_release.py --github-output "$GITHUB_OUTPUT"
|
|
backend_version=$(python3 -c "import re; text=open('backend/app/core/config.py').read(); print(re.search(r\"version: str = os\\.getenv\\('LINKLOG_VERSION', '([^']+)'\\)\", text).group(1))")
|
|
if [ "${GITHUB_REF_NAME#v}" != "$backend_version" ]; then
|
|
echo "tag ${GITHUB_REF_NAME} does not match backend version $backend_version" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: Log in to Gitea container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.kolkman.org
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build and publish Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
${{ env.IMAGE_NAME }}:${{ steps.release.outputs.backend_version }}
|
|
${{ env.IMAGE_NAME }}:latest
|
|
labels: |
|
|
org.opencontainers.image.version=${{ steps.release.outputs.backend_version }}
|
|
org.opencontainers.image.source=https://git.kolkman.org/olaf/Link-Log
|
|
|
|
- name: Generate release README
|
|
env:
|
|
BACKEND_VERSION: ${{ steps.release.outputs.backend_version }}
|
|
PLUGIN_VERSION: ${{ steps.release.outputs.plugin_version }}
|
|
SIGNED_XPI: ${{ steps.release.outputs.signed_xpi }}
|
|
run: |
|
|
cat > release-readme.md <<EOF
|
|
# LinkLog $BACKEND_VERSION
|
|
|
|
LinkLog is a Firefox extension and Python web service for saving links with a title, comment, timestamp, and tracking parameters removed. The service stores links in SQLite and can publish them through plugins, including Mastodon.
|
|
|
|
## Docker Container
|
|
|
|
The current backend/container version is $BACKEND_VERSION. Pull it from the Gitea container registry:
|
|
|
|
\`\`\`sh
|
|
docker pull $IMAGE_NAME:$BACKEND_VERSION
|
|
\`\`\`
|
|
|
|
The same image is also published as:
|
|
|
|
\`\`\`sh
|
|
docker pull $IMAGE_NAME:latest
|
|
\`\`\`
|
|
The developer version of the backend is always published as $IMAGE_NAME:latest, which may be ahead of the current release version and may be unstable.
|
|
Additional information about the backend can be found in the [README](https://git.kolkman.org/olaf/Link-Log/src/branch/main/backend/README.md).
|
|
|
|
## Firefox Extension
|
|
|
|
The current signed Firefox plugin version, compatible with this version of the backend, is $PLUGIN_VERSION. Download it from the raw repository artifact:
|
|
|
|
https://git.kolkman.org/olaf/Link-Log/raw/branch/main/$SIGNED_XPI
|
|
EOF
|
|
|
|
- name: Create Gitea release
|
|
id: gitea_release
|
|
env:
|
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
VERSION: ${{ steps.release.outputs.backend_version }}
|
|
run: |
|
|
payload_file=$(mktemp)
|
|
python3 - <<'PY' > "$payload_file"
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
version = os.environ['VERSION']
|
|
print(json.dumps({
|
|
'tag_name': f'v{version}',
|
|
'name': f'LinkLog {version}',
|
|
'body': Path('release-readme.md').read_text(),
|
|
'draft': False,
|
|
'prerelease': False,
|
|
}))
|
|
PY
|
|
response_file=$(mktemp)
|
|
response_status=$(curl --silent --show-error -o "$response_file" -w '%{http_code}' \
|
|
-X POST \
|
|
-H "Authorization: token $RELEASE_TOKEN" \
|
|
-H 'Content-Type: application/json' \
|
|
--data-binary "@$payload_file" \
|
|
https://git.kolkman.org/api/v1/repos/olaf/Link-Log/releases)
|
|
rm -f "$payload_file"
|
|
if [ "$response_status" = 409 ]; then
|
|
response_status=$(curl --silent --show-error -o "$response_file" -w '%{http_code}' \
|
|
-H "Authorization: token $RELEASE_TOKEN" \
|
|
"https://git.kolkman.org/api/v1/repos/olaf/Link-Log/releases/tags/v$VERSION")
|
|
fi
|
|
if [ "$response_status" -lt 200 ] || [ "$response_status" -ge 300 ]; then
|
|
cat "$response_file" >&2
|
|
exit 1
|
|
fi
|
|
response=$(cat "$response_file")
|
|
rm -f "$response_file"
|
|
release_id=$(printf '%s' "$response" | python3 -c 'import json, sys; print(json.load(sys.stdin)["id"])')
|
|
test "$release_id" != null
|
|
test "$release_id" != 0
|
|
upload_url="https://git.kolkman.org/api/v1/repos/olaf/Link-Log/releases/$release_id/assets"
|
|
echo "upload_url=$upload_url" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Upload release README
|
|
env:
|
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
UPLOAD_URL: ${{ steps.gitea_release.outputs.upload_url }}
|
|
run: |
|
|
response_status=$(curl --silent --show-error -o /tmp/linklog-readme-upload-response -w '%{http_code}' \
|
|
-X POST -H "Authorization: token $RELEASE_TOKEN" \
|
|
-H 'Content-Type: text/markdown' \
|
|
--data-binary @release-readme.md \
|
|
"$UPLOAD_URL?name=README.md")
|
|
if [ "$response_status" -lt 200 ] || [ "$response_status" -ge 300 ]; then
|
|
cat /tmp/linklog-readme-upload-response >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: Publish release links
|
|
env:
|
|
BACKEND_VERSION: ${{ steps.release.outputs.backend_version }}
|
|
PLUGIN_VERSION: ${{ steps.release.outputs.plugin_version }}
|
|
SIGNED_XPI: ${{ steps.release.outputs.signed_xpi }}
|
|
run: |
|
|
echo "Docker image: $IMAGE_NAME:$BACKEND_VERSION"
|
|
echo "Signed XPI: https://git.kolkman.org/olaf/Link-Log/raw/branch/main/$SIGNED_XPI (version $PLUGIN_VERSION)"
|
|
echo "Release README: README.md"
|