Sync release #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync release | |
| on: | |
| workflow_dispatch: | |
| repository_dispatch: | |
| types: [sync-release] | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| SOURCE_REPO: 'bindhosts/bindhosts' | |
| MODULE_NAME: 'bindhosts' | |
| jobs: | |
| get_missing_tags: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tags: ${{ steps.check.outputs.tags }} | |
| steps: | |
| - name: Check tags | |
| id: check | |
| run: | | |
| SOURCE_TAGS=$(gh api repos/$SOURCE_REPO/tags | jq -r '.[].name' | sort) | |
| CURRENT_TAGS=$(gh api repos/$GITHUB_REPOSITORY/tags | jq -r '.[].name' | sort) | |
| MISSING=$(comm -23 <(echo "$SOURCE_TAGS") <(echo "$CURRENT_TAGS")) | |
| MISSING_JSON=$(echo "$MISSING" | jq -R -s -c 'split("\n")[:-1]') | |
| echo "tags=$MISSING_JSON" >> $GITHUB_OUTPUT | |
| sync_and_release: | |
| needs: get_missing_tags | |
| if: needs.get_missing_tags.outputs.tags != '[]' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| tag: ${{ fromJson(needs.get_missing_tags.outputs.tags) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| token: ${{ secrets.REPO_SYNC_PAT }} | |
| - name: Pull release artifact and notes | |
| run: | | |
| gh release download ${{ matrix.tag }} --repo $SOURCE_REPO --pattern "$MODULE_NAME.zip" | |
| BODY=$(gh release view ${{ matrix.tag }} --repo $SOURCE_REPO --json body -q .body) | |
| echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV | |
| echo "$BODY" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Create Release | |
| uses: KernelSU-Modules-Repo/module_release@main | |
| with: | |
| tag_name: ${{ matrix.tag }} | |
| file: "${{ env.MODULE_NAME }}.zip" | |
| body: ${{ env.RELEASE_BODY }} | |
| generate_release_notes: true | |
| - uses: actions/attest-build-provenance@v3 | |
| with: | |
| subject-path: "${{ env.MODULE_NAME }}.zip" |