100 lines
3.1 KiB
YAML
100 lines
3.1 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main # or your default branch
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: self-hosted
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # fetch full history
|
|
tags: true # fetch all tags
|
|
|
|
- name: Check/Create Tag
|
|
id: tag
|
|
run: |
|
|
VERSION=$(cat VERSION | tr -d '[:space:]') # read version and trim whitespace
|
|
echo "Version: $VERSION"
|
|
|
|
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
|
echo "Tag v$VERSION already exists. Skipping release."
|
|
exit 0
|
|
fi
|
|
|
|
# Tag does not exist → create it
|
|
echo "Creating tag v$VERSION"
|
|
git tag "v$VERSION"
|
|
git push origin "v$VERSION"
|
|
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Extract version changelog
|
|
if: steps.tag.outputs.version
|
|
id: changelog
|
|
run: |
|
|
VERSION="${{ steps.tag.outputs.version }}"
|
|
CHANGELOG_FILE=$(python3 scripts/get_changelog.py $VERSION)
|
|
|
|
if [[ $? != 0 ]]; then
|
|
echo "No changelog found for version $VERSION"
|
|
exit 1
|
|
fi
|
|
|
|
cat "$CHANGELOG_FILE"
|
|
echo "changelog_file=$CHANGELOG_FILE" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build Artifacts
|
|
if: steps.tag.outputs.version
|
|
run: |
|
|
chmod +x ./package
|
|
./package
|
|
ls -l dist/
|
|
|
|
- name: Create Release
|
|
if: steps.tag.outputs.version
|
|
id: create_release
|
|
run: |
|
|
VERSION="${{ steps.tag.outputs.version }}"
|
|
CHANGELOG_FILE="${{ steps.changelog.outputs.changelog_file }}"
|
|
RESPONSE=$(jq -n \
|
|
--arg tag "v$VERSION" \
|
|
--arg name "wapp-v$VERSION" \
|
|
--rawfile body "$CHANGELOG_FILE" \
|
|
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}' \
|
|
| curl -s -X POST \
|
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
--data-binary @- \
|
|
"https://git.thewizardapprentice.com/api/v1/repos/${{ gitea.repository }}/releases")
|
|
|
|
echo "$RESPONSE"
|
|
RELEASE_ID=$(echo $RESPONSE | jq -r '.id')
|
|
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
|
|
|
|
- name: Upload Artifacts
|
|
if: steps.tag.outputs.version
|
|
run: |
|
|
RELEASE_ID="${{ steps.create_release.outputs.release_id }}"
|
|
for FILE in dist/*; do
|
|
FILENAME=$(basename "$FILE")
|
|
echo "Uploading $FILENAME"
|
|
curl -X POST \
|
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
--data-binary @"$FILE" \
|
|
"https://git.thewizardapprentice.com/api/v1/repos/${{ gitea.repository }}/releases/$RELEASE_ID/assets?name=$FILENAME"
|
|
done
|
|
|
|
- name: Cleanup
|
|
if: steps.tag.outputs.version
|
|
run: |
|
|
CHANGELOG_FILE="${{ steps.changelog.outputs.changelog_file }}"
|
|
rm -rf dist/*
|
|
rm -f "$CHANGELOG_FILE"
|