Skip to content

Commit

Permalink
Merge pull request #10 from Stevemoretz/main
Browse files Browse the repository at this point in the history
Automatic overwrite for the latest tag on push triggers, add basic test job
  • Loading branch information
AMIR ABBAS authored Apr 18, 2023
2 parents 71203e9 + 3199d45 commit cd01db8
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
53 changes: 50 additions & 3 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ on:
jobs:
check_tag:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Check latest tag
id: check_tag
if: github.event_name != 'push'
run: |
tag1=$(curl -s https://api.github.com/repos/MatsuriDayo/nekoray/tags | jq -r '.[0].name')
tag2=$(curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/tags | jq -r '.[0].name')
Expand Down Expand Up @@ -46,9 +46,41 @@ jobs:
name: nekoray_arm64
path: nekoray/build/nekoray_arm64.zip

test:
strategy:
matrix:
os: [macos-10.15, macos-11, macos-12]
arch: [amd64, arm64]

runs-on: ${{ matrix.os }}
needs: build

steps:
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: nekoray_${{ matrix.arch }}
path: ./

- name: Unzip Artifact
run: |
unzip -q nekoray_${{ matrix.arch }}.zip
mv nekoray_${{ matrix.arch }}.app nekoray.app
- name: Run Nekoray
run: |
./nekoray.app/Contents/MacOS/nekoray > nekoray.log 2>&1 &
nekoray_pid=$!
sleep 10
if ! ps -p "$nekoray_pid" > /dev/null; then
echo "Nekoray failed to stay open for 10 seconds."
cat nekoray.log
exit 1
fi
create_release:
runs-on: ubuntu-latest
needs: build
needs: test
permissions:
contents: write
packages: write
Expand Down Expand Up @@ -76,6 +108,20 @@ jobs:
echo "Latest tag is ${latest_tag}"
echo "latest_tag=${latest_tag}" >> $GITHUB_ENV
- name: Check if release already exists
id: check_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
releases=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.latest_tag }})
if [[ -n $releases && $releases != *"Not Found"* ]]; then
echo "Release ${{env.latest_tag}} already exists, deleting..."
release_id=$(echo $releases | jq -r .id)
curl -X DELETE -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/$release_id
curl -X DELETE -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${{ env.latest_tag }}" || true
sleep 10
fi
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -86,8 +132,9 @@ jobs:
release_name: ${{ env.latest_tag }} macOS
body: Built on the original repository. ${{ env.latest_tag }}
draft: false
published: true
prerelease: ${{ contains(env.latest_tag, 'pre') }}

- name: Upload Release Asset for amd64
id: upload_release_asset_amd64
uses: actions/upload-release-asset@v1
Expand Down
15 changes: 12 additions & 3 deletions nekoray_macos_builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,18 @@ for cmd in "nekobox_core" "nekoray_core"; do
done

#zip nekoray by arch
for arch in "amd64" "arm64"; do
zip -r "$nPath/build/nekoray_$arch.zip" "$nPath/build/nekoray_$arch.app"
done
if [ -n "$GITHUB_ACTIONS" ]; then
for arch in "amd64" "arm64"; do
TEMP_PATH=$(pwd)
cd "$nPath/build"
zip -r "nekoray_$arch.zip" "nekoray_$arch.app"
cd "$TEMP_PATH"
done
else
for arch in "amd64" "arm64"; do
zip -r "$nPath/build/nekoray_$arch.zip" "$nPath/build/nekoray_$arch.app"
done
fi

echo "Build finished and output files are in $nPath/build"
cd "$nPath"
Expand Down

0 comments on commit cd01db8

Please sign in to comment.