diff --git a/.github/workflows/sync-samples-on-release.yml b/.github/workflows/sync-samples-on-release.yml new file mode 100644 index 0000000..f7f80b6 --- /dev/null +++ b/.github/workflows/sync-samples-on-release.yml @@ -0,0 +1,42 @@ +name: Sync Samples On Release + +on: + release: + types: + - published + - prereleased + +permissions: + contents: read + +jobs: + sync-samples: + runs-on: ubuntu-latest + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + SAMPLES_REPOSITORY: ${{ vars.LENGA_SAMPLES_REPOSITORY || 'lengaengine/example-games' }} + SAMPLES_REPOSITORY_TOKEN: ${{ secrets.SAMPLES_REPOSITORY_TOKEN }} + steps: + - name: Dispatch released version to samples when configured + shell: bash + run: | + set -euo pipefail + + if [[ -z "$SAMPLES_REPOSITORY_TOKEN" ]]; then + echo '::notice::Skipping sample synchronization because SAMPLES_REPOSITORY_TOKEN is not configured.' + exit 0 + fi + + VERSION="${RELEASE_TAG#v}" + if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then + echo "::warning::Skipping sample synchronization because '$RELEASE_TAG' is not a supported semantic version." + exit 0 + fi + + if ! GH_TOKEN="$SAMPLES_REPOSITORY_TOKEN" gh api \ + --method POST \ + "repos/$SAMPLES_REPOSITORY/dispatches" \ + --raw-field event_type=engine-released \ + --raw-field "client_payload[version]=$VERSION"; then + echo "::warning::Could not notify $SAMPLES_REPOSITORY. The engine release remains valid." + fi diff --git a/.github/workflows/verify-release-version.yml b/.github/workflows/verify-release-version.yml index fa3d956..63fded4 100644 --- a/.github/workflows/verify-release-version.yml +++ b/.github/workflows/verify-release-version.yml @@ -42,34 +42,3 @@ jobs: echo "VERSION mismatch: tag is '$VERSION_TAG' but VERSION contains '$FILE_VERSION'." >&2 exit 1 fi - - notify-samples: - if: ${{ github.event_name == 'release' }} - needs: verify-release-version - runs-on: ubuntu-latest - env: - RELEASE_TAG: ${{ github.event.release.tag_name }} - SAMPLES_REPOSITORY: ${{ vars.LENGA_SAMPLES_REPOSITORY || 'lengaengine/example-games' }} - SAMPLES_REPOSITORY_TOKEN: ${{ secrets.SAMPLES_REPOSITORY_TOKEN }} - steps: - - name: Dispatch released version to samples - shell: bash - run: | - set -euo pipefail - - if [[ -z "$SAMPLES_REPOSITORY_TOKEN" ]]; then - echo 'SAMPLES_REPOSITORY_TOKEN is required to synchronize public samples.' >&2 - exit 1 - fi - - VERSION="${RELEASE_TAG#v}" - if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then - echo "Release tag '$RELEASE_TAG' is not a supported semantic version." >&2 - exit 1 - fi - - GH_TOKEN="$SAMPLES_REPOSITORY_TOKEN" gh api \ - --method POST \ - "repos/$SAMPLES_REPOSITORY/dispatches" \ - --raw-field event_type=engine-released \ - --raw-field "client_payload[version]=$VERSION"