diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 7d9859f..7b32e15 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -8,6 +8,10 @@ on: - "v*" workflow_dispatch: +permissions: + contents: write + releases: write + jobs: build: runs-on: ubuntu-latest @@ -38,26 +42,9 @@ jobs: ls -la dist-release - name: Create release and upload assets - env: - TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - set -eu - [ -n "${TOKEN}" ] || { echo "ERROR: no token available (secrets.GITHUB_TOKEN is empty)"; exit 1; } - API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" - if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then - TAG="${GITHUB_REF_NAME}" - else - TAG="build-${GITHUB_RUN_NUMBER}" - fi - echo "Creating release ${TAG} on ${API}" - curl -sS --fail-with-body -X POST "$API/releases" \ - -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" \ - -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"target_commitish\":\"${GITHUB_SHA}\"}" \ - -o release.json - RELEASE_ID=$(sed -n 's/.*"id":\([0-9]*\).*/\1/p' release.json | head -1) - echo "Release id: ${RELEASE_ID}" - for f in dist-release/*; do - echo "Uploading $f" - curl -sS --fail-with-body -X POST "$API/releases/${RELEASE_ID}/assets?name=$(basename "$f")" \ - -H "Authorization: token ${TOKEN}" -F "attachment=@${f}" - done + uses: https://gitea.com/actions/gitea-release-action@v1 + with: + tag_name: ${{ github.ref_type == 'tag' && github.ref_name || format('build-{0}', github.run_number) }} + target_commitish: ${{ github.sha }} + files: |- + dist-release/*