|
9 | 9 | jobs:
|
10 | 10 | check_tag:
|
11 | 11 | runs-on: ubuntu-latest
|
12 |
| - |
13 | 12 | steps:
|
14 | 13 | - uses: actions/checkout@v2
|
15 | 14 | - name: Check latest tag
|
16 | 15 | id: check_tag
|
| 16 | + if: github.event_name != 'push' |
17 | 17 | run: |
|
18 | 18 | tag1=$(curl -s https://api.github.com/repos/MatsuriDayo/nekoray/tags | jq -r '.[0].name')
|
19 | 19 | tag2=$(curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/tags | jq -r '.[0].name')
|
|
46 | 46 | name: nekoray_arm64
|
47 | 47 | path: nekoray/build/nekoray_arm64.zip
|
48 | 48 |
|
| 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 | +
|
49 | 81 | create_release:
|
50 | 82 | runs-on: ubuntu-latest
|
51 |
| - needs: build |
| 83 | + needs: test |
52 | 84 | permissions:
|
53 | 85 | contents: write
|
54 | 86 | packages: write
|
@@ -76,6 +108,20 @@ jobs:
|
76 | 108 | echo "Latest tag is ${latest_tag}"
|
77 | 109 | echo "latest_tag=${latest_tag}" >> $GITHUB_ENV
|
78 | 110 |
|
| 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 | +
|
79 | 125 | - name: Create Release
|
80 | 126 | id: create_release
|
81 | 127 | uses: actions/create-release@v1
|
|
86 | 132 | release_name: ${{ env.latest_tag }} macOS
|
87 | 133 | body: Built on the original repository. ${{ env.latest_tag }}
|
88 | 134 | draft: false
|
| 135 | + published: true |
89 | 136 | prerelease: ${{ contains(env.latest_tag, 'pre') }}
|
90 |
| - |
| 137 | + |
91 | 138 | - name: Upload Release Asset for amd64
|
92 | 139 | id: upload_release_asset_amd64
|
93 | 140 | uses: actions/upload-release-asset@v1
|
|
0 commit comments