.local-bin/.github/workflows/release.yml
Jeremie Fraeys 740a790436
Some checks failed
Create Release / release (push) Failing after 4s
Add Zig setup step to release workflow
2026-02-09 14:44:51 -05:00

68 lines
2.2 KiB
YAML

---
name: Create Release
on:
push:
branches:
- main
paths:
- 'manwhere'
- '.github/workflows/release.yml'
jobs:
release:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Zig
run: |
if ! command -v zig &> /dev/null; then
brew install zig
fi
zig version
- name: Run tests
run: |
cd scripts/manwhere && zig build test
- name: Get version from commit
id: version
run: |
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "v0.1.0-$(git rev-parse --short HEAD)")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Create Release
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
# Delete existing release with same tag if exists
curl -s -X DELETE \
-H "Authorization: token $GITEA_TOKEN" \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/$VERSION" || true
# Create new release
curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"$VERSION\",
\"name\": \"manwhere $VERSION\",
\"body\": \"Release of manwhere binary\\n\\nBuilt from commit: ${{ github.sha }}\",
\"target_commitish\": \"main\"
}" \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" | tee release.json
RELEASE_ID=$(jq -r '.id' release.json)
# Upload binary
curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @manwhere \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=manwhere&attachment=true"
echo "Release created: ${{ github.server_url }}/${{ github.repository }}/releases/tag/$VERSION"