diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..99d734f0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +name: Release Piper Action + +on: + workflow_dispatch: # trigger release manually + schedule: + - cron: '0 9 * * 1' # at 9 am every Monday + +jobs: + check_if_should_run: + name: Check if should run + runs-on: ubuntu-latest + outputs: + should_run: ${{ steps.should_run.outputs.should_run }} + steps: + - uses: actions/checkout@v4 + + # For scheduled runs check if there has been a commit in the last week + - id: should_run + if: ${{ github.event_name == 'schedule' }} + name: Check latest commits + run: | + if [[ -n $(git rev-list --after="7 days" ${{ github.sha }}) ]] + then + echo "should_run=true" >> "$GITHUB_OUTPUT" + else + echo "No commits for the past 7 days" + fi + + # For manual release trigger + - if: ${{ github.event_name == 'workflow_dispatch' }} + run: echo "should_run=true" >> "$GITHUB_OUTPUT" + + release: + name: Release + needs: check_if_should_run + if: ${{ needs.check_if_should_run.outputs.should_run == 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Increment version + id: version + uses: reecetech/version-increment@2024.4.1 + with: + scheme: semver + increment: minor + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.version.outputs.version }} + generate_release_notes: true + make_latest: true