File tree Expand file tree Collapse file tree 2 files changed +98
-0
lines changed Expand file tree Collapse file tree 2 files changed +98
-0
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' ) . promises ;
2+ const { ARTIFACT_NAME , ASSET_NAME , GITHUB_REF } = process . env ;
3+
4+ module . exports = async ( { github, context } ) => {
5+ const {
6+ repo : {
7+ owner,
8+ repo,
9+ } ,
10+ } = context ;
11+ const tag = GITHUB_REF . replace ( 'refs/tags/' , '' ) ;
12+
13+ const release = await github . repos . getReleaseByTag ( {
14+ owner,
15+ repo,
16+ tag,
17+ } ) ;
18+
19+ const files = await fs . readdir ( './target/release' ) ;
20+
21+ for ( let file of files ) {
22+ if ( file === ASSET_NAME ) {
23+ await github . repos . uploadReleaseAsset ( {
24+ owner,
25+ repo,
26+ release_id : release . data . id ,
27+ name : ARTIFACT_NAME ,
28+ data : await fs . readFile ( file ) ,
29+ } ) ;
30+ }
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ name : Upload Artifacts
2+
3+ on :
4+ release :
5+ types :
6+ - published
7+
8+ jobs :
9+ build :
10+ name : Setup workflows for ${{ matrix.os }}
11+ runs-on : ${{ matrix.os }}
12+ env :
13+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
14+ strategy :
15+ matrix :
16+ name :
17+ - linux
18+ - macos
19+ - windows
20+
21+ include :
22+ - name : linux
23+ os : ubuntu-latest
24+ artifact_name : http-server
25+ asset_name : http-server
26+
27+ - name : macos
28+ os : macos-linux
29+ artifact_name : http-server
30+ asset_name : http-server
31+
32+ - name : windows
33+ os : windows-latest
34+ artifact_name : http-server
35+ asset_name : http-server.exe
36+
37+ steps :
38+ - name : Checkout project files
39+ uses : actions/checkout@v2
40+
41+ - name : Cache .cargo and target
42+ uses : actions/cache@v2
43+ with :
44+ path : |
45+ ~/.cargo
46+ ./target
47+ key : ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.toml') }}
48+ restore-keys : |
49+ ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
50+ ${{ runner.os }}-cargo-build
51+
52+ - name : Builds artifacts for {{ matrix.os }}
53+ uses : actions-rs/cargo@v1
54+ with :
55+ command : build
56+ args : --release --locked
57+
58+ - name : Upload release artifacts
59+ uses : actions/github-script@v5
60+ env :
61+ ARTIFACT_NAME : ${{ matrix.artifact_name }}
62+ ASSET_NAME : ${{ matrix.asset_name }}
63+ with :
64+ script : |
65+ const script = require('./.github/workflows/scripts/upload-artifacts.js');
66+ console.log(script({ github, context }));
You can’t perform that action at this time.
0 commit comments