Skip to content

Commit 5781505

Browse files
author
NeOMakinG
authored
Merge pull request #399 from Progi1984/ga_createArtifact
GA : Create artifact (and release)
2 parents fe0c34c + 27ac3d6 commit 5781505

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

.github/workflows/build.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
2+
name: Build ZIP File
3+
on:
4+
pull_request:
5+
push:
6+
workflow_dispatch:
7+
8+
jobs:
9+
deploy:
10+
name: Build dependencies & create artifact
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
- name: Setup node env
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: 14
20+
21+
- name: Install dependencies
22+
run: npm i
23+
24+
- name: Copy Webpack config
25+
run: cp ./webpack/.env-example ./webpack/.env
26+
27+
- name: Build assets
28+
run: npm run build
29+
30+
- name: Remove dependencies
31+
run: rm node_modules/ .github/ .git/ -rf
32+
33+
- name: Create & Upload artifact
34+
uses: actions/upload-artifact@v1
35+
with:
36+
name: ${{ github.event.repository.name }}
37+
path: ../
38+
update_release_draft:
39+
runs-on: ubuntu-latest
40+
needs: [deploy]
41+
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
42+
steps:
43+
- name: Download artifact
44+
uses: actions/download-artifact@v1
45+
with:
46+
name: ${{ github.event.repository.name }}
47+
48+
- id: release_info
49+
uses: toolmantim/release-drafter@v5
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Prepare for Release
54+
run: |
55+
cd ${{ github.event.repository.name }}
56+
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }}
57+
58+
- name: Clean existing assets
59+
shell: bash
60+
run: |
61+
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
62+
assets=`bin/hub api -t repos/${{ github.repository }}/releases/${{ steps.release_info.outputs.id }}/assets | awk '/\].url/ { print $2 }'`
63+
for asset in $assets
64+
do
65+
bin/hub api -X DELETE $asset
66+
done
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Publish to GitHub Release
71+
uses: actions/upload-release-asset@v1.0.1
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
with:
75+
upload_url: ${{ steps.release_info.outputs.upload_url }}
76+
asset_path: ./${{ github.event.repository.name }}/${{ github.event.repository.name }}.zip
77+
asset_name: ${{ github.event.repository.name }}.zip
78+
asset_content_type: application/zip

0 commit comments

Comments
 (0)