Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelburnham committed Aug 23, 2024
1 parent 33afcb8 commit a51b188
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
38 changes: 16 additions & 22 deletions .github/workflows/bump-version-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
#- name: Git config
# run: |
# git config --global user.name "argument-ci[bot]"
# git config --global user.email "argument-ci[bot]@users.noreply.github.com"
- name: Git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Rust
uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -73,21 +75,25 @@ jobs:
if [[ "${{ inputs.type }}" == "release" ]]; then
git checkout -b $BASE_BRANCH
git push origin $BASE_BRANCH
else
git checkout $BASE_BRANCH
fi
echo "BASE_VERSION=$BASE_VERSION" | tee -a $GITHUB_ENV
echo "BASE_BRANCH=$BASE_BRANCH" | tee -a $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}

- name: Create `version-bump` branch
- name: Create PR branch
run: |
if [[ "${{ inputs.type }}" == "hotfix" ]]; then
VERSION=${{ inputs.version }}
PR_BRANCH="${{ inputs.type }}/${{ inputs.light-client }}-v${{ inputs.version }}"
else
VERSION=$BASE_VERSION
PR_BRANCH="version-bump"
fi
git checkout -b $PR_BRANCH
echo "VERSION=$VERSION" | tee -a $GITHUB_ENV
Expand Down Expand Up @@ -160,9 +166,9 @@ jobs:

# Note: Can't use `peter-evans/create-pull-request` because for hotfixes we need to make the PR with an existing branch
# The former always creates a new one for single-commit PRs, thus overwriting the actual hotfix
- name: Create PR description
- name: Create PR
run: |
PR_BODY=$(cat <<EOF
cat << 'EOF' > body.md
This is an automated release PR for version `${{ env.VERSION }}` of the ${{ inputs.light-client }} light client.
Please update the Sphinx dependency versions to the appropriate release tag manually. (TODO: Automate)
Expand All @@ -171,19 +177,7 @@ jobs:
[Workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
EOF
)
echo "PR_DESCRIPTION=$PR_DESCRIPTION" >> $GITHUB_ENV
- name: Create Pull Request
uses: actions/github-script@v6
with:
github-token: ${{ secrets.REPO_TOKEN }}
script: |
github.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "${{ env.PR_TITLE }}",
head: "${{ env.PR_BRANCH }}",
base: "${{ env.BASE_BRANCH }}",
body: "${{ env.PR_DESCRIPTION }}",
})
gh pr create --title "${{ env.PR_TITLE }}" --body-file ./body.md --head ${{ env.PR_BRANCH }} --base ${{ env.BASE_BRANCH }}
env:
GH_TOKEN: ${{ secrets.REPO_TOKEN }}
12 changes: 7 additions & 5 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
id: get-version
run: |
RELEASE_BRANCH=${{ github.event.pull_request.base.ref }}
TAG_VERSION=$(echo "$RELEASE_BRANCH | cut -d'/' -f 2)
PATH=$(echo "$RELEASE_BRANCH" | awk -F'/' '{split($2, arr, "-"); print arr[1]}')
TAG_VERSION=$(echo "$RELEASE_BRANCH" | cut -d'/' -f 2)
LC_PATH=$(echo "$RELEASE_BRANCH" | awk -F'/' '{split($2, arr, "-"); print arr[1]}')
if [[ "${{ startsWith(github.event.pull_request.head.ref, 'version-bump') }}" == "true" ]]; then
TAG_VERSION="${TAG_VERSION}.0"
Expand All @@ -47,10 +47,10 @@ jobs:
run: |
if [[ "${{ github.event.pull_request.head.ref }}" == "version-bump" ]]; then
REGEX=${{ env.PATH }}
LATEST_RELEASE=$(gh release list --repo $GITHUB_REPOSITORY --limit 100 | grep -Ei "$REGEX" | head -n 1 | awk '{ print $1 }')
LATEST_RELEASE=$(gh release list --repo ${{ github.repository }} --limit 100 | grep -Ei "$REGEX" | head -n 1 | awk '{ print $1 }')
if [ -z "$LATEST_RELEASE" ]; then
LATEST_RELEASE=$(git rev-list --max-parents=0 ${{ github.event.repository.default_branch }})
LATEST_RELEASE=$(git rev-list --max-parents=0 HEAD)
echo "The first commit on branch ${{ env.RELEASE_BRANCH }} is $LATEST_RELEASE"
else
echo "Found release: $LATEST_RELEASE"
Expand All @@ -61,6 +61,8 @@ jobs:
echo "Found release: $LATEST_RELEASE"
fi
echo "latest_release=$LATEST_RELEASE" | tee -a "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}

- name: Build Changelog
id: github_release
Expand All @@ -76,6 +78,6 @@ jobs:
uses: ncipollo/release-action@v1
with:
body: ${{ steps.github_release.outputs.changelog }}
tag: ${{ steps.get-version.outputs.version }}
tag: ${{ steps.get-version.outputs.tag-version }}
commit: ${{ env.RELEASE_BRANCH }}
allowUpdates: true

0 comments on commit a51b188

Please sign in to comment.