name: release on: push: branches: [main] jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.RELEASE_TOKEN }} - name: Determine version and guard against re-release id: version run: | set -e VERSION=$(grep -m1 '"version"' composer.json | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/') TAG="v${VERSION}" echo "version=${VERSION}" >> "$GITHUB_OUTPUT" echo "tag=${TAG}" >> "$GITHUB_OUTPUT" if git ls-remote --tags origin "refs/tags/${TAG}" | grep -q "${TAG}"; then echo "skip=true" >> "$GITHUB_OUTPUT" echo "Tag ${TAG} already exists, nothing to release." else echo "skip=false" >> "$GITHUB_OUTPUT" fi - name: Extract changelog section if: steps.version.outputs.skip == 'false' run: | awk -v ver="${{ steps.version.outputs.version }}" ' BEGIN { found=0 } /^## \[/ { if (found) exit if ($0 ~ "\[" ver "\]") { found=1; next } } found { print } ' CHANGELOG.md > release-notes.md cat release-notes.md - name: Create and push tag if: steps.version.outputs.skip == 'false' run: | git config user.name "gitea-actions" git config user.email "actions@git.arthurerlich.de" git tag "${{ steps.version.outputs.tag }}" git push origin "${{ steps.version.outputs.tag }}" - name: Install shopware-cli if: steps.version.outputs.skip == 'false' run: | curl -sL -o /tmp/shopware-cli.tar.gz \ https://github.com/shopware/shopware-cli/releases/latest/download/shopware-cli_Linux_x86_64.tar.gz mkdir -p /tmp/swcli-extract tar -xzf /tmp/shopware-cli.tar.gz -C /tmp/swcli-extract cp /tmp/swcli-extract/shopware-cli /usr/local/bin/shopware-cli - name: Validate extension (informational only, does not gate the release) if: steps.version.outputs.skip == 'false' run: shopware-cli extension validate . || true - name: Package Store-style zip for the Gitea Release asset if: steps.version.outputs.skip == 'false' run: | shopware-cli extension package . --output-directory .build \ --filename "AeonDumpManager-${{ steps.version.outputs.tag }}.zip" - name: Build root-level zip for the Composer registry if: steps.version.outputs.skip == 'false' run: git archive --format=zip -o "composer-package-${{ steps.version.outputs.tag }}.zip" "${{ steps.version.outputs.tag }}" - name: Create Gitea Release if: steps.version.outputs.skip == 'false' uses: akkuman/gitea-release-action@v1 with: server_url: ${{ vars.SERVER_URL }} token: ${{ secrets.RELEASE_TOKEN }} tag_name: ${{ steps.version.outputs.tag }} name: ${{ steps.version.outputs.tag }} body_path: release-notes.md files: .build/AeonDumpManager-${{ steps.version.outputs.tag }}.zip - name: Publish to Composer registry if: steps.version.outputs.skip == 'false' run: | STATUS=$(curl -s -o /tmp/composer-publish.log -w "%{http_code}" \ -u "haylan:${{ secrets.RELEASE_TOKEN }}" \ -T "composer-package-${{ steps.version.outputs.tag }}.zip" \ "https://git.arthurerlich.de/api/packages/haylan/composer") cat /tmp/composer-publish.log if [ "$STATUS" != "201" ] && [ "$STATUS" != "409" ]; then echo "Unexpected HTTP status $STATUS publishing to the Composer registry" exit 1 fi