first commit

This commit is contained in:
Kevin Robert Andrews
2026-03-31 18:21:02 -04:00
commit a517ebb7cc
4 changed files with 114 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
name: Release
on:
push:
tags:
- 'v*'
env:
GITEA_HOST: git.kappow.ca
REPO: kevin/mm
MODULE_ID: mm
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set version from tag
id: vars
run: |
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG#v}"
echo "TAG=$TAG" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Update module.json version and download URL
run: |
jq \
--arg version "${{ steps.vars.outputs.VERSION }}" \
--arg download "https://${{ env.GITEA_HOST }}/${{ env.REPO }}/releases/download/${{ steps.vars.outputs.TAG }}/${{ env.MODULE_ID }}.zip" \
'.version = $version | .download = $download' \
module.json > /tmp/module.json
mv /tmp/module.json module.json
- name: Commit updated module.json back to main
run: |
git config user.name "Gitea Actions"
git config user.email "actions@${{ env.GITEA_HOST }}"
git fetch origin main
git checkout main
# Re-apply the version bump on main
jq \
--arg version "${{ steps.vars.outputs.VERSION }}" \
--arg download "https://${{ env.GITEA_HOST }}/${{ env.REPO }}/releases/download/${{ steps.vars.outputs.TAG }}/${{ env.MODULE_ID }}.zip" \
'.version = $version | .download = $download' \
module.json > /tmp/module.json
mv /tmp/module.json module.json
git add module.json
git diff --cached --quiet || git commit -m "chore: release ${{ steps.vars.outputs.TAG }}"
git push "https://actions:${{ secrets.GITEA_TOKEN }}@${{ env.GITEA_HOST }}/${{ env.REPO }}.git" main
git checkout ${{ steps.vars.outputs.TAG }}
- name: Create module zip
run: |
# Re-apply module.json changes (we're back on the tag commit)
jq \
--arg version "${{ steps.vars.outputs.VERSION }}" \
--arg download "https://${{ env.GITEA_HOST }}/${{ env.REPO }}/releases/download/${{ steps.vars.outputs.TAG }}/${{ env.MODULE_ID }}.zip" \
'.version = $version | .download = $download' \
module.json > /tmp/module.json
mv /tmp/module.json module.json
zip -r ${{ env.MODULE_ID }}.zip . \
--exclude ".git/*" \
--exclude ".gitea/*" \
--exclude "*.zip"
- name: Create Gitea release
id: create_release
run: |
RESPONSE=$(curl -s -X POST \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"${{ steps.vars.outputs.TAG }}\",
\"name\": \"${{ steps.vars.outputs.TAG }}\",
\"body\": \"Release ${{ steps.vars.outputs.TAG }}\"
}" \
"https://${{ env.GITEA_HOST }}/api/v1/repos/${{ env.REPO }}/releases")
echo "RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')" >> $GITHUB_OUTPUT
- name: Upload module zip
run: |
curl -s -X POST \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-F "attachment=@${{ env.MODULE_ID }}.zip" \
"https://${{ env.GITEA_HOST }}/api/v1/repos/${{ env.REPO }}/releases/${{ steps.create_release.outputs.RELEASE_ID }}/assets"
- name: Upload module.json
run: |
curl -s -X POST \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-F "attachment=@module.json" \
"https://${{ env.GITEA_HOST }}/api/v1/repos/${{ env.REPO }}/releases/${{ steps.create_release.outputs.RELEASE_ID }}/assets"