-
Notifications
You must be signed in to change notification settings - Fork 1
55 lines (53 loc) · 1.9 KB
/
release_draft.yaml
File metadata and controls
55 lines (53 loc) · 1.9 KB
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
name: Create Release Draft
on:
workflow_run:
workflows: [ "Build My First Game" ]
branches: [ master ]
types:
- completed
jobs:
draft:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
GH_REPO: ${{ github.repository }}
steps:
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.27.0
with:
branch: master
workflow: build.yaml
path: download
workflow_conclusion: success
- run: |
mkdir dist
# Extract MyFirstGame from Linux (x64)
cp download/"Linux (x64)"/MyFirstGame dist/MyFirstGame-Linux-x64
# Extract MyFirstGame from Mac
cp download/"MacOS (Universal)"/MyFirstGame dist/MyFirstGame-macOS-universal
# Extract MyFirstGame.exe from Windows (x64)/Release
cp download/"Windows (x64)"/Release/MyFirstGame.exe dist/MyFirstGame-Windows-x64.exe
- name: Check for Existing Drafts
id: check_drafts
uses: actions/github-script@v6
with:
script: |
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
})
const draft = releases.find(release => release.draft);
return draft ? draft.tag_name : false;
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create or Update Release Draft
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ steps.check_drafts.outputs.result }}" == "false" ]; then
echo "creating a new release draft"
gh release create new --draft dist/**
else
echo "updating an existing release draft"
gh release upload "${{ steps.check_drafts.outputs.result }}" dist/** --clobber
fi