forked from abbasnaqdi/nekoray-macos
-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (136 loc) · 4.7 KB
/
action.yml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Build and Release Nekoray
on:
schedule:
- cron: '0 0 * * *' # Run every day at midnight UTC
push:
branches: [main]
workflow_dispatch:
inputs:
publish:
description: 'Publish: If want ignore'
required: false
artifact-pack:
description: 'artifact-pack: If want ignore'
required: false
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.21
- name: Build Nekoray
run: |
bash builder.sh
- name: Upload Artifact for amd64
uses: actions/upload-artifact@v2
with:
name: nekoray_amd64
path: nekoray/build/nekoray_amd64.zip
- name: Upload Artifact for arm64
uses: actions/upload-artifact@v2
with:
name: nekoray_arm64
path: nekoray/build/nekoray_arm64.zip
test:
strategy:
matrix:
os: [macos-11, macos-12, macos-13]
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: test
permissions:
contents: write
packages: write
actions: read
pull-requests: write
issues: write
steps:
- name: Download Artifact for amd64
uses: actions/download-artifact@v2
with:
name: nekoray_amd64
path: ./
- name: Download Artifact for arm64
uses: actions/download-artifact@v2
with:
name: nekoray_arm64
path: ./
- name: Check latest tag
id: check_tag
run: |
latest_tag=$(git ls-remote --tags --sort=-v:refname https://github.com/MatsuriDayo/nekoray.git | head -n1 | awk '{print $2}' | sed 's/refs\/tags\///')
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.latest_tag }}
release_name: ${{ env.latest_tag }}
body: Built on the original repository.
draft: false
published: true
prerelease: ${{ contains(env.latest_tag, 'pre') }}
- name: Set Release URL
run: echo "RELEASE_URL=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_ENV
- name: Upload Release Asset for amd64
id: upload_release_asset_amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_URL }}
asset_path: nekoray_amd64.zip
asset_name: nekoray-${{ env.latest_tag }}-macos-amd64.zip
asset_content_type: application/zip
- name: Upload Release Asset for arm64
id: upload_release_asset_arm64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_URL }}
asset_path: nekoray_arm64.zip
asset_name: nekoray-${{ env.latest_tag }}-macos-arm64.zip
asset_content_type: application/zip