-
Notifications
You must be signed in to change notification settings - Fork 17
76 lines (66 loc) · 2.35 KB
/
ssc-draft-release.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
name: SSC draft release
on:
workflow_dispatch:
schedule:
- cron: '00 00 * * *'
env:
SC4S_OWNER: splunk
SC4S_REPO: splunk-connect-for-syslog
jobs:
detect-version:
if: github.repository_owner == 'axoflow'
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.version.outputs.new_version }}
steps:
- name: Detect SC4S version
id: version
uses: actions/github-script@v6
with:
script: |
const { SC4S_OWNER, SC4S_REPO } = process.env;
const latest_release = await github.rest.repos.getLatestRelease({
owner: SC4S_OWNER,
repo: SC4S_REPO,
});
if (!/^v[0-9]/.test(latest_release.data.tag_name)) {
core.setFailed('Latest release tag mismatch');
return;
}
const new_version = latest_release.data.tag_name.substring(1);
console.log('Version (latest): ' + new_version);
const ssc_releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const release_exists = !!ssc_releases.data.find((release) => {
return release.name == "ssc-" + new_version;
});
if (!release_exists)
core.setOutput('new_version', new_version)
test:
if: needs.detect-version.outputs.new_version
uses: ./.github/workflows/ssc-test.yml
needs: detect-version
with:
owner: splunk
repo: splunk-connect-for-syslog
ref: v${{ needs.detect-version.outputs.new_version }}
draft-release:
if: always() && needs.detect-version.outputs.new_version
needs: [detect-version, test]
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Report test issue
if: contains(needs.test.result, 'failure')
run: |
gh issue create --title "ssc-${{ needs.detect-version.outputs.new_version }}" \
--body "ssc-${{ needs.detect-version.outputs.new_version }} test failed"
- name: Draft release
run: |
gh release create --draft --target "main" --title "ssc-${{ needs.detect-version.outputs.new_version }}" \
"ssc-${{ needs.detect-version.outputs.new_version }}"