|
| 1 | +name: Sync release |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + repository_dispatch: |
| 5 | + types: [sync-release] |
| 6 | + |
| 7 | +permissions: |
| 8 | + id-token: write |
| 9 | + contents: write |
| 10 | + actions: write |
| 11 | + attestations: write |
| 12 | + |
| 13 | +env: |
| 14 | + GH_TOKEN: ${{ github.token }} |
| 15 | + SOURCE_REPO: 'bindhosts/bindhosts' |
| 16 | + MODULE_NAME: 'bindhosts' |
| 17 | + |
| 18 | +jobs: |
| 19 | + get_missing_tags: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + outputs: |
| 22 | + tags: ${{ steps.check.outputs.tags }} |
| 23 | + steps: |
| 24 | + - name: Check tags |
| 25 | + id: check |
| 26 | + run: | |
| 27 | + SOURCE_TAGS=$(gh api repos/$SOURCE_REPO/tags | jq -r '.[].name' | sort) |
| 28 | + CURRENT_TAGS=$(gh api repos/$GITHUB_REPOSITORY/tags | jq -r '.[].name' | sort) |
| 29 | + MISSING=$(comm -23 <(echo "$SOURCE_TAGS") <(echo "$CURRENT_TAGS")) |
| 30 | + MISSING_JSON=$(echo "$MISSING" | jq -R -s -c 'split("\n")[:-1]') |
| 31 | + echo "tags=$MISSING_JSON" >> $GITHUB_OUTPUT |
| 32 | +
|
| 33 | + sync_and_release: |
| 34 | + needs: get_missing_tags |
| 35 | + if: needs.get_missing_tags.outputs.tags != '[]' |
| 36 | + runs-on: ubuntu-latest |
| 37 | + strategy: |
| 38 | + matrix: |
| 39 | + tag: ${{ fromJson(needs.get_missing_tags.outputs.tags) }} |
| 40 | + steps: |
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@v6 |
| 43 | + with: |
| 44 | + token: ${{ secrets.REPO_SYNC_PAT }} |
| 45 | + |
| 46 | + - name: Pull release artifact and notes |
| 47 | + run: | |
| 48 | + gh release download ${{ matrix.tag }} --repo $SOURCE_REPO --pattern "$MODULE_NAME.zip" |
| 49 | + BODY=$(gh release view ${{ matrix.tag }} --repo $SOURCE_REPO --json body -q .body) |
| 50 | + echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV |
| 51 | + echo "$BODY" >> $GITHUB_ENV |
| 52 | + echo "EOF" >> $GITHUB_ENV |
| 53 | +
|
| 54 | + - name: Create Release |
| 55 | + uses: KernelSU-Modules-Repo/module_release@main |
| 56 | + with: |
| 57 | + tag_name: ${{ matrix.tag }} |
| 58 | + file: "${{ env.MODULE_NAME }}.zip" |
| 59 | + body: ${{ env.RELEASE_BODY }} |
| 60 | + generate_release_notes: true |
| 61 | + |
| 62 | + - uses: actions/attest-build-provenance@v3 |
| 63 | + with: |
| 64 | + subject-path: "${{ env.MODULE_NAME }}.zip" |
0 commit comments