Skip to content

Commit cd01db8

Browse files
author
AMIR ABBAS
authored
Merge pull request #10 from Stevemoretz/main
Automatic overwrite for the latest tag on push triggers, add basic test job
2 parents 71203e9 + 3199d45 commit cd01db8

File tree

2 files changed

+62
-6
lines changed

2 files changed

+62
-6
lines changed

.github/workflows/blank.yml

+50-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ on:
99
jobs:
1010
check_tag:
1111
runs-on: ubuntu-latest
12-
1312
steps:
1413
- uses: actions/checkout@v2
1514
- name: Check latest tag
1615
id: check_tag
16+
if: github.event_name != 'push'
1717
run: |
1818
tag1=$(curl -s https://api.github.com/repos/MatsuriDayo/nekoray/tags | jq -r '.[0].name')
1919
tag2=$(curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/tags | jq -r '.[0].name')
@@ -46,9 +46,41 @@ jobs:
4646
name: nekoray_arm64
4747
path: nekoray/build/nekoray_arm64.zip
4848

49+
test:
50+
strategy:
51+
matrix:
52+
os: [macos-10.15, macos-11, macos-12]
53+
arch: [amd64, arm64]
54+
55+
runs-on: ${{ matrix.os }}
56+
needs: build
57+
58+
steps:
59+
- name: Download Artifact
60+
uses: actions/download-artifact@v2
61+
with:
62+
name: nekoray_${{ matrix.arch }}
63+
path: ./
64+
65+
- name: Unzip Artifact
66+
run: |
67+
unzip -q nekoray_${{ matrix.arch }}.zip
68+
mv nekoray_${{ matrix.arch }}.app nekoray.app
69+
70+
- name: Run Nekoray
71+
run: |
72+
./nekoray.app/Contents/MacOS/nekoray > nekoray.log 2>&1 &
73+
nekoray_pid=$!
74+
sleep 10
75+
if ! ps -p "$nekoray_pid" > /dev/null; then
76+
echo "Nekoray failed to stay open for 10 seconds."
77+
cat nekoray.log
78+
exit 1
79+
fi
80+
4981
create_release:
5082
runs-on: ubuntu-latest
51-
needs: build
83+
needs: test
5284
permissions:
5385
contents: write
5486
packages: write
@@ -76,6 +108,20 @@ jobs:
76108
echo "Latest tag is ${latest_tag}"
77109
echo "latest_tag=${latest_tag}" >> $GITHUB_ENV
78110
111+
- name: Check if release already exists
112+
id: check_release
113+
env:
114+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115+
run: |
116+
releases=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.latest_tag }})
117+
if [[ -n $releases && $releases != *"Not Found"* ]]; then
118+
echo "Release ${{env.latest_tag}} already exists, deleting..."
119+
release_id=$(echo $releases | jq -r .id)
120+
curl -X DELETE -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/$release_id
121+
curl -X DELETE -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${{ env.latest_tag }}" || true
122+
sleep 10
123+
fi
124+
79125
- name: Create Release
80126
id: create_release
81127
uses: actions/create-release@v1
@@ -86,8 +132,9 @@ jobs:
86132
release_name: ${{ env.latest_tag }} macOS
87133
body: Built on the original repository. ${{ env.latest_tag }}
88134
draft: false
135+
published: true
89136
prerelease: ${{ contains(env.latest_tag, 'pre') }}
90-
137+
91138
- name: Upload Release Asset for amd64
92139
id: upload_release_asset_amd64
93140
uses: actions/upload-release-asset@v1

nekoray_macos_builder.sh

+12-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,18 @@ for cmd in "nekobox_core" "nekoray_core"; do
127127
done
128128

129129
#zip nekoray by arch
130-
for arch in "amd64" "arm64"; do
131-
zip -r "$nPath/build/nekoray_$arch.zip" "$nPath/build/nekoray_$arch.app"
132-
done
130+
if [ -n "$GITHUB_ACTIONS" ]; then
131+
for arch in "amd64" "arm64"; do
132+
TEMP_PATH=$(pwd)
133+
cd "$nPath/build"
134+
zip -r "nekoray_$arch.zip" "nekoray_$arch.app"
135+
cd "$TEMP_PATH"
136+
done
137+
else
138+
for arch in "amd64" "arm64"; do
139+
zip -r "$nPath/build/nekoray_$arch.zip" "$nPath/build/nekoray_$arch.app"
140+
done
141+
fi
133142

134143
echo "Build finished and output files are in $nPath/build"
135144
cd "$nPath"

0 commit comments

Comments
 (0)