-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (72 loc) · 2.6 KB
/
sync.yml
File metadata and controls
82 lines (72 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Sync release
on:
workflow_dispatch:
repository_dispatch:
types: [sync-release]
permissions:
id-token: write
contents: write
actions: write
attestations: write
env:
GH_TOKEN: ${{ github.token }}
SOURCE_REPO: "Rem01Gaming/encore"
MODULE_NAME: "encore"
jobs:
get_tags:
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.check.outputs.tags }}
latest: ${{ steps.check.outputs.latest }}
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] | map(select(. != ""))')
echo "tags=$MISSING_JSON" >> $GITHUB_OUTPUT
LATEST=$(echo "$SOURCE_TAGS" | tail -1)
echo "latest=$LATEST" >> $GITHUB_OUTPUT
release:
needs: get_tags
if: needs.get_tags.outputs.tags != '[]'
runs-on: ubuntu-latest
strategy:
matrix:
tag: ${{ fromJson(needs.get_tags.outputs.tags) }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.REPO_SYNC_PAT }}
- name: Find and download artifact
id: download
run: |
ASSETS_JSON=$(gh api repos/$SOURCE_REPO/releases/tags/${{ matrix.tag }} --jq '.assets')
ASSET_NAME=$(echo "$ASSETS_JSON" | jq -r '.[].name | select(startswith("encore") and endswith(".zip"))')
if [ -z "$ASSET_NAME" ]; then
echo "No artifact found matching pattern"
exit 1
fi
echo "Found asset: $ASSET_NAME"
gh release download ${{ matrix.tag }} --repo $SOURCE_REPO --pattern "$ASSET_NAME"
echo "asset_name=$ASSET_NAME" >> $GITHUB_OUTPUT
- name: Get release body
id: body
run: |
BODY=$(gh release view ${{ matrix.tag }} --repo $SOURCE_REPO --json body -q .body)
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "$BODY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: KernelSU-Modules-Repo/module_release@main
with:
tag_name: ${{ matrix.tag }}
make_latest: ${{ matrix.tag == needs.get_tags.outputs.latest }}
file: "${{ steps.download.outputs.asset_name }}"
body: ${{ steps.body.outputs.body }}
- uses: actions/attest-build-provenance@v3
with:
subject-path: "${{ steps.download.outputs.asset_name }}"