-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (107 loc) · 4.27 KB
/
release-assets.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
name: Compile assets
on:
release:
types:
- released
jobs:
compile-release-assets:
strategy:
fail-fast: false
matrix:
node-version: [16.x]
config:
- os: ubuntu-latest
artifact: DistributionZ-${{ github.event.release.tag_name }}.AppImage
updater-file: latest-linux.yml
- os: macos-latest
artifact: DistributionZ-${{ github.event.release.tag_name }}.dmg
- os: macos-latest
artifact: DistributionZ-${{ github.event.release.tag_name }}-mac.zip
updater-file: latest-mac.yml
- os: windows-latest
artifact: DistributionZ Setup ${{ github.event.release.tag_name }}.exe
updater-file: latest.yml
runs-on: ${{ matrix.config.os }}
name: Compile release asset ${{ matrix.config.artifact }} for ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v3
- name: Build on Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.5.1
with:
node-version: ${{ matrix.node-version }}
- name: Set version
shell: bash
run: |
npm version --no-git-tag-version ${{ github.event.release.tag_name }}
- uses: actions/cache@v3
with:
path: |
~/.yarn
.yarn
node_modules
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
- run: yarn --frozen-lockfile
- run: |
yarn build
name: Build
- name: Create sha256 of release asset
shell: bash
# if macos-latest, use shasum -a 256
if: ${{ matrix.config.os == 'macos-latest' }}
run: |
shasum -a 256 "dist/${{ matrix.config.artifact }}" > dist/${{ matrix.config.artifact }}.sha256sum
- name: Create sha256 of release asset
shell: bash
# if ubuntu-latest, use sha256sum
if: ${{ matrix.config.os != 'macos-latest' }}
run: |
sha256sum "dist/${{ matrix.config.artifact }}" > "dist/${{ matrix.config.artifact }}.sha256sum"
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
id: upload-release-asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/${{ matrix.config.artifact }}
asset_name: ${{ matrix.config.artifact }}
asset_content_type: application/octet-stream
- name: Upload Release Asset sha256sum
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/${{ matrix.config.artifact }}.sha256sum
asset_name: ${{ matrix.config.artifact }}.sha256sum
asset_content_type: text/plain
- name: Upload Release Asset Updater File
uses: actions/github-script@v6
if: ${{ matrix.config.updater-file }}
env:
FILE_URL: ${{ steps.upload-release-asset.outputs.browser_download_url }}
with:
script: |
const latestJSON = {
releaseNotes: context.payload.release.body,
releaseName: `Savannah ${context.payload.release.tag_name}`,
version: context.payload.release.tag_name,
files: []
};
// Read checksum from file
const checksum = require('fs').readFileSync(`dist/${{ matrix.config.artifact }}.sha256sum`, 'utf8').split(' ')[0];
// Remove all from the url except after the last slash
const url = process.env.FILE_URL.replace(`https://github.com/TheDome/DistributionZ/releases/download/${context.payload.release.tag_name}`, '');
console.log("Filename is ", url);
latestJSON.files.push({
url,
sha2: checksum,
});
// Upload release file
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: context.payload.release.id,
name: "${{ matrix.config.updater-file }}",
data: JSON.stringify(latestJSON, null, 2)
});