|
1 | 1 | name: Build and Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - 'v*' |
7 | | - branches: |
8 | | - - main |
| 4 | + release: |
| 5 | + types: [published] |
9 | 6 |
|
10 | 7 | env: |
11 | 8 | BUILD_TYPE: Release |
@@ -72,20 +69,36 @@ jobs: |
72 | 69 | runs-on: ubuntu-latest |
73 | 70 |
|
74 | 71 | steps: |
| 72 | + - name: Install jq |
| 73 | + run: sudo apt-get install -y jq |
| 74 | + |
75 | 75 | - name: Download Linux artifacts |
76 | 76 | uses: actions/download-artifact@v3 |
77 | 77 | with: |
78 | 78 | name: HeronTriangle-Linux |
79 | | - path: ./linux |
| 79 | + path: ./artifacts/linux |
| 80 | + |
80 | 81 | - name: Download Windows artifacts |
81 | 82 | uses: actions/download-artifact@v3 |
82 | 83 | with: |
83 | 84 | name: HeronTriangle-Windows |
84 | | - path: ./windows |
85 | | - |
86 | | - - name: Create GitHub Release |
87 | | - uses: softprops/action-gh-release@v1 |
88 | | - with: |
89 | | - files: | |
90 | | - linux/HeronTriangle-Linux.zip |
91 | | - windows/HeronTriangle-Windows.zip |
| 85 | + path: ./artifacts/windows |
| 86 | + |
| 87 | + - name: Attach Artifacts to Release |
| 88 | + env: |
| 89 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + run: | |
| 91 | + release_id=$(curl -s \ |
| 92 | + -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 93 | + https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.id') |
| 94 | + echo "Release ID: $release_id" |
| 95 | +
|
| 96 | + for file in ./artifacts/linux/* ./artifacts/windows/*; do |
| 97 | + filename=$(basename "$file") |
| 98 | + echo "Uploading $filename to release $release_id" |
| 99 | + curl -X POST \ |
| 100 | + -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 101 | + -H "Content-Type: application/zip" \ |
| 102 | + --data-binary @"$file" \ |
| 103 | + "https://uploads.github.com/repos/${{ github.repository }}/releases/$release_id/assets?name=$filename" |
| 104 | + done |
0 commit comments