Skip to content

Commit

Permalink
Add test changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil committed Apr 18, 2024
1 parent bab8abe commit aa444bd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ jobs:
- name: Increment version and assemble changelog
run: |
nix-build -A autoVersion
version=$(result/bin/auto-version .)
version=$(result/bin/auto-version . ${{ github.event.pull_request.number || '' }})
git commit --all --message "Version $version
Automated release"
echo "version=$version" >> "$GITHUB_ENV"
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -44,13 +48,7 @@ jobs:

- name: Update release branch
if: ${{ env.version && github.event_name == 'push' }}
run: |
git config user.name infinixbot
git config user.email [email protected]
git commit --all --message 'Version ${{ env.version }}
Automated release'
git push origin HEAD:release
run: git push origin HEAD:release


test-update:
Expand Down
3 changes: 3 additions & 0 deletions changes/unreleased/minor/add-changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add changelog

This is just a test to show that changelogs are actually used!
13 changes: 7 additions & 6 deletions scripts/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ set -euo pipefail
shopt -s nullglob

root=$1
currentPrNumber=${2:-}

[[ "$(toml get --raw Cargo.toml package.version)" =~ ([0-9]+)\.([0-9]+)\.([0-9]+) ]]
[[ "$(toml get --raw "$root"/Cargo.toml package.version)" =~ ([0-9]+)\.([0-9]+)\.([0-9]+) ]]
splitVersion=( "${BASH_REMATCH[@]:1}" )

majorChanges=( "$root"/changes/unreleased/major/*.md )
Expand Down Expand Up @@ -37,7 +38,7 @@ echo "" >> "$releaseFile"

# shellcheck disable=SC2016
for file in "${majorChanges[@]}" "${mediumChanges[@]}" "${minorChanges[@]}"; do
commit=$(git log -1 --format=%H -- "$file")
commit=$(git -C "$root" log -1 --show-pulls --format=%H -- "$file")
if ! gh api graphql \
-f sha="$commit" \
-f query='
Expand All @@ -57,12 +58,12 @@ for file in "${majorChanges[@]}" "${mediumChanges[@]}" "${minorChanges[@]}"; do
}
}
}
}' | \
jq --exit-status -r --arg file "$file" '
}' | tee /dev/stderr | \
jq --exit-status -r ${currentPrNumber:+--argjson currentPrNumber "$currentPrNumber"} --arg file "$file" '
.data.repository.commit.associatedPullRequests?.nodes?[]?
| select(
# We need to make sure to get the right PR, there can be many
.merged and
(.merged or .number == $ARGS.named.currentPrNumber) and
.baseRepository.nameWithOwner == "NixOS/nixpkgs-check-by-name" and
.baseRefName == "main")
| "\(.number) \(.author.login) \($ARGS.named.file)"'; then
Expand All @@ -81,5 +82,5 @@ while read -r number author file; do
rm "$file"
done

cargo set-version "$next"
cargo set-version --manifest-path "$root"/Cargo.toml "$next"
echo "$next"

0 comments on commit aa444bd

Please sign in to comment.