diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index b7b3d02..5217bf7 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -10,8 +10,21 @@ jobs: runs-on: ubuntu-latest steps: - - name: Code auschecken - uses: actions/checkout@v4 + - name: Code herunterladen + run: | + VERSION="${{ github.ref_name }}" + curl -sSL -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + -o source.tar.gz \ + "https://git.wende.it/marco/WitShop/archive/${VERSION}.tar.gz" + tar xzf source.tar.gz + # Gitea entpackt in einen Unterordner WitShop-{version}/ + SRCDIR=$(tar tzf source.tar.gz 2>/dev/null | head -1 | cut -d/ -f1 || true) + if [ -n "$SRCDIR" ] && [ -d "$SRCDIR" ]; then + mv "$SRCDIR"/* . 2>/dev/null || true + mv "$SRCDIR"/.[!.]* . 2>/dev/null || true + rmdir "$SRCDIR" 2>/dev/null || true + fi + rm -f source.tar.gz - name: Node.js einrichten uses: actions/setup-node@v4 @@ -51,19 +64,32 @@ jobs: echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Release in Gitea veröffentlichen - uses: https://gitea.com/actions/release-action@main - with: - files: ${{ env.PACKAGE }} - api_key: ${{ secrets.RELEASE_TOKEN }} - title: "WITshop ${{ env.VERSION }}" - body: | - ## WITshop ${{ env.VERSION }} + run: | + # Release erstellen (oder existierenden verwenden) + RELEASE_ID=$(curl -sSL -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + "https://git.wende.it/api/v1/repos/marco/WitShop/releases/tags/${{ github.ref_name }}" \ + | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('id',''))" 2>/dev/null || true) - ### Installation (Erstinstallation) - 1. ZIP herunterladen und auf den Server entpacken - 2. `install.sh` ausführen: `bash install.sh` - 3. Fertig + if [ -z "$RELEASE_ID" ]; then + RELEASE_ID=$(curl -sSL -X POST \ + -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + -H "Content-Type: application/json" \ + "https://git.wende.it/api/v1/repos/marco/WitShop/releases" \ + -d "{ + \"tag_name\": \"${{ github.ref_name }}\", + \"name\": \"WITshop ${{ github.ref_name }}\", + \"body\": \"## WITshop ${{ github.ref_name }}\n\n### Installation (Erstinstallation)\n1. ZIP herunterladen und auf den Server entpacken\n2. \`install.sh\` ausführen: \`bash install.sh\`\n3. Fertig\n\n### Update (bestehende Installation)\n1. ZIP herunterladen und auf den Server entpacken\n2. \`update.sh\` ausführen: \`bash update.sh\`\", + \"draft\": false, + \"prerelease\": false + }" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") + fi - ### Update (bestehende Installation) - 1. ZIP herunterladen und auf den Server entpacken - 2. `update.sh` ausführen: `bash update.sh` + echo "Release ID: $RELEASE_ID" + + # ZIP anhängen + curl -sSL -X POST \ + -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + -F "attachment=@${{ env.PACKAGE }}" \ + "https://git.wende.it/api/v1/repos/marco/WitShop/releases/${RELEASE_ID}/assets?name=${{ env.PACKAGE }}" + + echo "ZIP erfolgreich hochgeladen: ${{ env.PACKAGE }}"