notepad/.gitea/workflows/release.yaml

162 lines
6.5 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-gitea
steps:
- name: Prep For Local Builds
run: echo "${LOCIP} gitea.comnenos" >> /etc/hosts
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install Build Dependencies
run: |
apt update
apt -y --no-install-recommends install \
wget \
file \
fuse \
libfuse2 \
python3 \
python3-pip \
zip
- name: Install .NET SDK
run: |
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x dotnet-install.sh
./dotnet-install.sh --channel 8.0 --install-dir /usr/local/dotnet
ln -sf /usr/local/dotnet/dotnet /usr/bin/dotnet
- name: Setup FUSE and AppImageTool
run: |
# Install and load FUSE
modprobe fuse || echo "Warning: Could not load fuse module"
# Download and extract appimagetool without FUSE (using --appimage-extract)
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage \
-O appimagetool.AppImage
chmod +x appimagetool.AppImage
./appimagetool.AppImage --appimage-extract
# Create wrapper script that uses extracted version
echo '#!/bin/bash' > /usr/local/bin/appimagetool
echo '/workspace/gmgauthier/notepad/squashfs-root/AppRun "$@"' >> /usr/local/bin/appimagetool
chmod +x /usr/local/bin/appimagetool
- name: Build Packages
run: |
cd NotePad
python3 publish.py both
- name: Create Release Archive
run: |
VERSION=${GITHUB_REF#refs/tags/}
VERSION_NUM=${VERSION#v} # Remove 'v' prefix (e.g., v0.1.4 -> 0.1.4)
mkdir -p release
# Copy AppImage (if it exists) - use version from build
if [ -f publish/appimage/NotePad-${VERSION_NUM}-x86_64.AppImage ]; then
cp publish/appimage/NotePad-${VERSION_NUM}-x86_64.AppImage \
release/NotePad-${VERSION}-x86_64.AppImage
fi
# Copy Linux Tarball
cp publish/tarball/notepad-${VERSION_NUM}-linux-x64.tar.gz \
release/notepad-${VERSION}-linux-x64.tar.gz
# Create Windows zip
cd publish/win-x64
zip -r ../../release/notepad-${VERSION}-win-x64.zip .
cd ../..
# Generate checksums
cd release
if [ -f NotePad-${VERSION}-x86_64.AppImage ]; then
sha256sum NotePad-${VERSION}-x86_64.AppImage > NotePad-${VERSION}-x86_64.AppImage.sha256
fi
sha256sum notepad-${VERSION}-linux-x64.tar.gz > notepad-${VERSION}-linux-x64.tar.gz.sha256
sha256sum notepad-${VERSION}-win-x64.zip > notepad-${VERSION}-win-x64.zip.sha256
ls -lh # For debugging
- name: Create Release
env:
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
VERSION=${GITHUB_REF#refs/tags/}
# Get the tag annotation message (not the commit message)
echo "Fetching tag annotation for ${VERSION}"
TAG_MESSAGE=$(git tag -l -n99 --format='%(contents)' ${VERSION})
echo "Tag annotation: ${TAG_MESSAGE}"
# If empty, try alternative method
if [ -z "$TAG_MESSAGE" ]; then
echo "Trying alternative method..."
TAG_MESSAGE=$(git for-each-ref refs/tags/${VERSION} --format='%(contents)')
echo "Alternative result: ${TAG_MESSAGE}"
fi
# Create release body
RELEASE_BODY=$(printf "%s\n\n## Downloads\n\n### Linux\n- **AppImage**: Portable, single-file executable (no installation needed)\n- **Tarball**: Extract and run \`sudo ./install.sh\` to install\n\n### Windows\n- **Zip**: Extract and run \`NotePad.exe\`" "$TAG_MESSAGE")
# Escape the full body for JSON
RELEASE_BODY_JSON=$(printf '%s' "$RELEASE_BODY" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
# Create release
curl -X POST "https://repos.gmgauthier.com/api/v1/repos/${GITHUB_REPOSITORY}/releases" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"${VERSION}\",
\"name\": \"NotePad ${VERSION}\",
\"body\": \"${RELEASE_BODY_JSON}\"
}" > release_response.json
RELEASE_ID=$(cat release_response.json | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
# Upload AppImage if it exists
if [ -f release/NotePad-${VERSION}-x86_64.AppImage ]; then
curl -X POST "https://repos.gmgauthier.com/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=NotePad-${VERSION}-x86_64.AppImage" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @release/NotePad-${VERSION}-x86_64.AppImage
curl -X POST "https://repos.gmgauthier.com/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=NotePad-${VERSION}-x86_64.AppImage.sha256" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: text/plain" \
--data-binary @release/NotePad-${VERSION}-x86_64.AppImage.sha256
fi
# Upload Linux tarball
curl -X POST "https://repos.gmgauthier.com/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=notepad-${VERSION}-linux-x64.tar.gz" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/gzip" \
--data-binary @release/notepad-${VERSION}-linux-x64.tar.gz
curl -X POST "https://repos.gmgauthier.com/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=notepad-${VERSION}-linux-x64.tar.gz.sha256" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: text/plain" \
--data-binary @release/notepad-${VERSION}-linux-x64.tar.gz.sha256
# Upload Windows zip
curl -X POST "https://repos.gmgauthier.com/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=notepad-${VERSION}-win-x64.zip" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/zip" \
--data-binary @release/notepad-${VERSION}-win-x64.zip
curl -X POST "https://repos.gmgauthier.com/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=notepad-${VERSION}-win-x64.zip.sha256" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: text/plain" \
--data-binary @release/notepad-${VERSION}-win-x64.zip.sha256