Publish Release #104
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Publish Release | |
on: | |
schedule: | |
# At 0:00am each day on the default branch | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Version tag' | |
required: true | |
type: string | |
name: | |
description: 'Release name' | |
required: true | |
type: string | |
skip_tests: | |
description: 'Skip tests' | |
required: true | |
default: false | |
type: boolean | |
jobs: | |
# checks if there's a commit in last 24hr | |
check_date: | |
runs-on: ubuntu-latest | |
outputs: | |
should_run: ${{ steps.should_run.outputs.should_run }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: print latest_commit | |
run: echo ${{ github.sha }} | |
- id: should_run | |
continue-on-error: true | |
name: check latest commit is less than a day | |
run: | | |
test -z $(git rev-list --after="24 hours" ${{ github.sha }}) \ | |
&& echo "::set-output name=should_run::false" \ | |
|| (gh run cancel ${{ github.run_id }} \ | |
&& gh run watch ${{ github.run_id }}) | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish_release: | |
needs: check_date | |
if: ${{ github.event_name == 'workflow_dispatch' || needs.check_date.outputs.should_run != 'false' }} | |
runs-on: ubuntu-latest | |
container: maven:3-eclipse-temurin-8 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache local Maven repository | |
uses: actions/cache/restore@v3 | |
with: | |
path: /root/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build and Test with Maven | |
run: mvn -P '!add-dependencies-for-IDEA,full-build,include-front-end' -B package -DskipTests=${{ github.event_name == 'workflow_dispatch' && inputs.skip_tests || true }} --file flink-cyber/pom.xml | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
with: | |
tag_name: ${{ inputs.tag }} | |
name: ${{ inputs.name }} | |
draft: true | |
generate_release_notes: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
files: | | |
flink-cyber/cyber-csd/target/cyber-csd--* | |
flink-cyber/cyber-csd/target/CYBERSEC-* | |
flink-cyber/cyber-parcel/target/CYBERSEC-* | |
- name: Get current date | |
id: date | |
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
- name: Publish artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cybersec-${{ github.event_name == 'workflow_dispatch' && 'release' || 'nightly' }}-${{ env.CURRENT_DATE }} | |
path: | | |
flink-cyber/cyber-csd/target/cyber-csd--* | |
flink-cyber/cyber-csd/target/CYBERSEC-* | |
flink-cyber/cyber-parcel/target/CYBERSEC-* |