-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (143 loc) · 6.91 KB
/
sync-pr.yml
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Sync and PR
permissions:
contents: write
id-token: write
attestations: write
on:
workflow_dispatch:
workflow_call:
schedule:
- cron: "*/30 * * * *"
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
run:
runs-on: ubuntu-24.04
name: PHP ${{ matrix.php-version }}
strategy:
max-parallel: 1
matrix:
include:
- php-version: '8.1'
php-version-major: 8
php-version-minor: 1
- php-version: '8.2'
php-version-major: 8
php-version-minor: 2
- php-version: '8.3'
php-version-major: 8
php-version-minor: 3
- php-version: '8.4'
php-version-major: 8
php-version-minor: 4
steps:
- uses: actions/checkout@v4
with:
path: builder
ref: 'main'
- name: Update version info
id: version_update
run: |
cd builder
php generate.php ${{ matrix.php-version }}
cat winget-commit-message.md
cat winget-pr-template.md
if [[ -f "NEW_VERSION" ]]; then
echo "new_version=$(cat NEW_VERSION)" >> $GITHUB_OUTPUT
else
echo "new_version=none" >> $GITHUB_OUTPUT
fi
- name: Add job summary when new releases are found
if: contains('none', steps.version_update.outputs.new_version) == true
run: |
echo 'No new releases found.' >> $GITHUB_STEP_SUMMARY
- name: Clone PHPWatch/winget-pkgs
uses: actions/checkout@v4
if: contains('none', steps.version_update.outputs.new_version) == false
with:
repository: PHPWatch/winget-pkgs
path: winget-pkgs
token: ${{ secrets.PKGS_TOKEN }}
sparse-checkout: |
manifests/p/PHP
- name: Sync fork
if: contains('none', steps.version_update.outputs.new_version) == false
run: |
cd winget-pkgs
git remote add upstream https://github.com/microsoft/winget-pkgs.git
git pull upstream master --ff-only
git push origin master
cd ../
- name: "List dirs: generated"
run: find builder/manifests | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
- name: "List dirs: Upstream"
if: contains('none', steps.version_update.outputs.new_version) == false
run: find winget-pkgs/manifests/p/PHP/PHP | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
- uses: actions/[email protected]
if: contains('none', steps.version_update.outputs.new_version) == false
id: attest
name: Attest manifest file
with:
subject-path: builder/manifests/p/PHP/PHP/${{ matrix.php-version-major }}/${{ matrix.php-version-minor }}
- name: Add attest information
if: contains('none', steps.version_update.outputs.new_version) == false
run: |
printf "\n###### Manifest built [automatically](%s) and [attested](%s) by [PHPWatch/php-winget-manifest](%s).\n\n" "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" "${{ steps.attest.outputs.attestation-url }}" "https://github.com/PHPWatch/php-winget-manifest/" >> builder/winget-commit-message.md
printf "\n###### Manifest built [automatically](%s) and [attested](%s) by [PHPWatch/php-winget-manifest](%s).\n\n" "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" "${{ steps.attest.outputs.attestation-url }}" "https://github.com/PHPWatch/php-winget-manifest/" >> builder/winget-pr-template.md
printf "\n###### Manifest built [automatically](%s) and [attested](%s) by [PHPWatch/php-winget-manifest](%s).\n\n" "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" "${{ steps.attest.outputs.attestation-url }}" "https://github.com/PHPWatch/php-winget-manifest/"
cat builder/winget-commit-message.md
cat builder/winget-pr-template.md
- name: Generate commit message
id: commit_msg
if: contains('none', steps.version_update.outputs.new_version) == false
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | xxd -p)
echo "commit_msg<<$EOF" >> $GITHUB_OUTPUT
cat builder/winget-commit-message.md >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
echo "## New Version" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.version_update.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
echo "## Commit message" >> $GITHUB_STEP_SUMMARY
cat builder/winget-commit-message.md >> $GITHUB_STEP_SUMMARY
echo "## PR Content" >> $GITHUB_STEP_SUMMARY
cat builder/winget-pr-template.md >> $GITHUB_STEP_SUMMARY
- name: Remove old files from winget-pkgs
if: contains('none', steps.version_update.outputs.new_version) == false
run: |
rm -r winget-pkgs/manifests/p/PHP/PHP/${{ matrix.php-version-major }}/${{ matrix.php-version-minor }}
cp -r builder/manifests/p/PHP/PHP/${{ matrix.php-version-major }}/${{ matrix.php-version-minor }} winget-pkgs/manifests/p/PHP/PHP/${{ matrix.php-version-major }}/${{ matrix.php-version-minor }}
- name: Fast-forward own repo
if: contains('none', steps.version_update.outputs.new_version) == false
run: |
cd builder
git pull --ff-only
cd ../
- name: Commit data to own repo
uses: stefanzweifel/git-auto-commit-action@v5
if: contains('none', steps.version_update.outputs.new_version) == false
with:
commit_message: ${{ steps.commit_msg.outputs.commit_msg }}
branch: main
add_options: '-A'
repository: builder
tagging_message: ${{ steps.version_update.outputs.new_version }}
- name: Create Pull Request
id: create_pr
uses: peter-evans/create-pull-request@v7
if: contains('none', steps.version_update.outputs.new_version) == false
with:
token: ${{ secrets.PKGS_TOKEN }}
path: "winget-pkgs"
body-path: builder/winget-pr-template.md
add-paths: "manifests/p/PHP/PHP/${{ matrix.php-version-major }}/${{ matrix.php-version-minor }}/${{ steps.version_update.outputs.new_version }}"
commit-message: ${{ steps.commit_msg.outputs.commit_msg }}
title: "[PHP] Add new version `PHP.PHP.${{ matrix.php-version-major }}.${{ matrix.php-version-minor }}` - `${{ steps.version_update.outputs.new_version }}`"
committer: "Ayesh Karunaratne <[email protected]>"
author: "Ayesh Karunaratne <[email protected]>"
branch: "php-v-${{ steps.version_update.outputs.new_version }}"
- name: Add Pull request information
if: ${{ steps.create_pr.outputs.pull-request-url }}
run: |
echo "## PR ${{ steps.create_pr.outputs.pull-request-operation }}" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.create_pr.outputs.pull-request-url }}" >> $GITHUB_STEP_SUMMARY