-
Notifications
You must be signed in to change notification settings - Fork 186
76 lines (64 loc) · 2.56 KB
/
generate_changelog.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: Generate changelog in PR
on:
pull_request:
jobs:
verify-version:
name: Verify that version that triggered this workflow is greater than most recent release
runs-on: ubuntu-latest
outputs:
versionIsValid: ${{ steps.validVersion.outputs.versionIsValid }}
version: ${{ steps.validVersion.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
cache: 'npm'
cache-dependency-path: scripts/package-lock.json
- run: npm ci
working-directory: scripts
- name: Get version from Cargo.toml
id: lookupVersion
uses: mikefarah/yq@a198f72367ce9da70b564a2cc25399de8e27bf37
with:
cmd: yq -oy '"v" + .workspace.package.version' 'Cargo.toml'
- name: Get version from the latest releases
id: lookupVersionRelease
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: cptartur
repo: starknet-foundry
excludes: prerelease, draft
- name: Compare versions
id: validVersion
run: |
RELEASE_VERSION=${{ steps.lookupVersionRelease.outputs.release }}
COMMIT_VERSION=${{ steps.lookupVersion.outputs.result }}
echo "Project version from newest release = $RELEASE_VERSION"
echo "Project version from this commit = $COMMIT_VERSION"
IS_VALID=$(node ./scripts/compareVersions.js $RELEASE_VERSION $COMMIT_VERSION)
echo "versionIsValid=$IS_VALID" >> "$GITHUB_OUTPUT"
echo "version=$COMMIT_VERSION" >> "$GITHUB_OUTPUT"
- name: Output job skipped
if: ${{ steps.validVersion.outputs.versionIsValid == 'false' }}
run: echo "Version from commit is not greater from newest release, skipping build"
generate-changelog:
name: Convert unreleased section in CHANGELOG.md to new release
runs-on: ubuntu-latest
needs: verify-version
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- run: sed -i 's/\[Unreleased\]/\${{ }} - $(date '+%Y-%m-%d')/'
- name: Commit CHANGELOG.md
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add CHANGELOG.md
git commit -m "Add changes"
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: ${{ github.head_ref }}