Prep 0.8.4 #1
Workflow file for this run
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
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 }} |