Skip to content

Commit e389e3f

Browse files
committed
update
1 parent ecfc061 commit e389e3f

File tree

1 file changed

+65
-13
lines changed

1 file changed

+65
-13
lines changed

.github/workflows/build.yml

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,42 @@ jobs:
4343
# target: aarch64-unknown-linux-gnu
4444
# platform: linux/arm64
4545
# php-version: '8.2'
46+
# -
47+
# target: x86_64-unknown-linux-gnu
48+
# platform: linux/amd64
49+
# php-version: '8.3'
50+
# -
51+
# os: ubuntu-latest
52+
# target: aarch64-unknown-linux-gnu
53+
# platform: linux/arm64
54+
# php-version: '8.3'
4655
steps:
4756
- name: Checkout
4857
uses: actions/checkout@v2
4958
with:
5059
submodules: recursive
5160

52-
- uses: actions/cache@v2
61+
- uses: actions/cache@v4
5362
with:
5463
path: |
55-
~/.cargo/registry
56-
~/.cargo/git
57-
target
64+
~/.cargo/bin/
65+
~/.cargo/registry/index/
66+
~/.cargo/registry/cache/
67+
~/.cargo/git/db/
68+
target/
5869
key: ${{ matrix.php-version }}-${{ matrix.target }}
5970

6071
- name: Setup QEMU
61-
uses: docker/setup-qemu-action@v2
72+
uses: docker/setup-qemu-action@v3
6273

6374
- name: Set up Docker Buildx
6475
id: buildx
65-
uses: docker/setup-buildx-action@v2
76+
uses: docker/setup-buildx-action@v3
6677
with:
6778
driver-opts: network=host
6879

6980
- name: Setup docker
70-
uses: docker/build-push-action@v2
81+
uses: docker/build-push-action@v5
7182
with:
7283
context: .
7384
platforms: ${{ matrix.platform }}
@@ -83,19 +94,54 @@ jobs:
8394
- name: Rename file
8495
run: cp target/${{ matrix.target }}/release/lib${{ env.EXTENSION_NAME }}.so php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.so
8596

86-
- uses: actions/upload-artifact@v3
97+
- uses: actions/upload-artifact@v4
8798
with:
8899
name: php${{ matrix.php-version }}-${{ matrix.target }}
89100
path: php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.so
90-
- name: Release
91-
uses: softprops/action-gh-release@v1
92-
if: startsWith(github.ref, 'refs/tags/')
101+
102+
- name: Get Cargo Version
103+
id: cargo_version
104+
run: |
105+
VERSION=$(grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)".*/\1/')
106+
echo "VERSION=$VERSION" >> $GITHUB_ENV
107+
108+
- name: Check and Create Release
109+
id: release
110+
uses: actions/github-script@v6
93111
with:
94-
files: |
95-
php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.so
112+
script: |
113+
const version = process.env.VERSION;
114+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
115+
const { data: releases } = await github.rest.repos.listReleases({
116+
owner,
117+
repo
118+
});
119+
const releaseExists = releases.some(release => release.tag_name === version);
120+
if (!releaseExists) {
121+
const release = await github.rest.repos.createRelease({
122+
owner,
123+
repo,
124+
tag_name: version,
125+
name: `Release ${version}`,
126+
draft: false,
127+
prerelease: false
128+
});
129+
return { id: release.data.id };
130+
} else {
131+
return { id: releases.find(release => release.tag_name === version).id };
132+
}
96133
env:
134+
VERSION: ${{ env.VERSION }}
97135
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98136

137+
- name: Upload Release Asset
138+
uses: actions/upload-release-asset@v1
139+
with:
140+
upload_url: ${{ steps.release.outputs.upload_url }}
141+
asset_path: php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.so
142+
asset_name: php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.so
143+
asset_content_type: application/octet-stream
144+
99145
# macos:
100146
# runs-on: macos-latest
101147
# strategy:
@@ -119,6 +165,12 @@ jobs:
119165
# -
120166
# target: x86_64-apple-darwin
121167
# php-version: '8.2'
168+
# -
169+
# target: aarch64-apple-darwin
170+
# php-version: '8.3'
171+
# -
172+
# target: x86_64-apple-darwin
173+
# php-version: '8.3'
122174
#
123175
# steps:
124176
# - name: Checkout

0 commit comments

Comments
 (0)