Skip to content

SSC draft release

SSC draft release #392

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@v7
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@v4
- 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 }}"