-
Notifications
You must be signed in to change notification settings - Fork 24
75 lines (65 loc) · 2.27 KB
/
split.yml
File metadata and controls
75 lines (65 loc) · 2.27 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
name: Split Packages
on:
push:
branches: [main, develop]
tags: ['[0-9]*']
concurrency:
group: split-${{ github.ref }}
cancel-in-progress: false
env:
SPLIT_ORG: marko-php
jobs:
setup:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.list.outputs.packages }}
steps:
- uses: actions/checkout@v6
- name: List packages
id: list
run: |
packages=$(ls packages/ | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "packages=$packages" >> $GITHUB_OUTPUT
split:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
package: ${{ fromJson(needs.setup.outputs.packages) }}
fail-fast: false
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Configure git
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
- name: Install splitsh-lite
run: |
curl -sL https://github.com/splitsh/lite/releases/download/v1.0.1/lite_linux_amd64.tar.gz | tar xz
sudo mv splitsh-lite /usr/local/bin/splitsh-lite
- name: Split and push
env:
SPLIT_TOKEN: ${{ secrets.SPLIT_TOKEN }}
run: |
REPO="https://x-access-token:${SPLIT_TOKEN}@github.com/${SPLIT_ORG}/marko-${{ matrix.package }}.git"
SHA=$(splitsh-lite --prefix="packages/${{ matrix.package }}")
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
git push --force "$REPO" "${SHA}:refs/heads/main"
git push --force "$REPO" "${SHA}:refs/tags/${TAG}"
else
BRANCH="${GITHUB_REF#refs/heads/}"
git push --force "$REPO" "${SHA}:refs/heads/${BRANCH}"
fi
- name: Notify Packagist
if: startsWith(github.ref, 'refs/tags/')
env:
PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }}
run: |
curl -sf -X POST https://packagist.org/api/update-package \
-H "Content-Type: application/json" \
-H "Authorization: Bearer markshust:${PACKAGIST_TOKEN}" \
-d "{\"repository\":\"https://github.com/${SPLIT_ORG}/marko-${{ matrix.package }}\"}"