-
Notifications
You must be signed in to change notification settings - Fork 2
59 lines (49 loc) · 1.84 KB
/
automatic_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
name: "tagged-release"
on:
push:
branches:
- "main"
permissions:
contents: write
jobs:
check_files:
name: "Check files"
runs-on: "ubuntu-latest"
outputs:
FILES_UPDATED: ${{ steps.compare_commits.outputs.FILES_UPDATED }}
DATE: ${{ steps.compare_commits.outputs.DATE }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 3
- id: compare_commits
shell: pwsh
run: |
# Check if 'last_run_date' file was changed in the latest commit
$LastCommitDiff = git diff --name-only HEAD^ HEAD | Where-Object { $_ -match "^last_run_date$" }
$DateChanged = $LastCommitDiff.Length -gt 0
# Check if any publication was updated during last SuttaPublisher run
# (compare next to last and third to last commits)
$NextToLastCommitDiff = git diff --name-only HEAD^^ HEAD^ | Where-Object { $_ -notmatch "^(last_run_date|\.\/github.*)$" }
$PublicationsChanged = $NextToLastCommitDiff.Length -gt 0
# Save output
$FilesUpdated = $DateChanged -and $PublicationsChanged
"FILES_UPDATED=$FilesUpdated" >> $env:GITHUB_OUTPUT
$Date = Get-Date -Format 'yyyy-MM-dd'
"DATE=$Date" >> $env:GITHUB_OUTPUT
make_release:
name: Make release
runs-on: ubuntu-latest
needs: check_files
if: needs.check_files.outputs.FILES_UPDATED == 'True'
steps:
- uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
automatic_release_tag: "editions-${{ needs.check_files.outputs.DATE }}"
- uses: dev-drprasad/[email protected]
with:
keep_latest: 1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}