Skip to content

Commit

Permalink
ci: use git command
Browse files Browse the repository at this point in the history
/git/refs API supports the HEAD commit of the branch
https://github.com/orgs/community/discussions/68932#discussioncomment-7176743

Signed-off-by: knqyf263 <[email protected]>
  • Loading branch information
knqyf263 committed Oct 14, 2024
1 parent 42661a0 commit dcfe145
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,33 @@ jobs:
runs-on: ubuntu-latest
if: ${{ needs.check-release-commit.outputs.is_release == 'true' }}
steps:
- name: Tag release
if: ${{ needs.check-release-commit.outputs.version }}
uses: actions/github-script@v7
- name: Checkout specific commit
uses: actions/checkout@v4
with:
github-token: ${{ secrets.ORG_REPO_TOKEN }} # To trigger another workflow
script: |
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/v${{ needs.check-release-commit.outputs.version }}`,
sha: '${{ needs.check-release-commit.outputs.release_sha }}'
});
fetch-depth: 0
ref: ${{ needs.check-release-commit.outputs.release_sha }}
token: ${{ secrets.ORG_REPO_TOKEN }}

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Create and push tag
env:
VERSION: ${{ needs.check-release-commit.outputs.version }}
run: |
git tag "v$VERSION"
git push --tags
- name: Create release branch
if: ${{ endsWith(needs.check-release-commit.outputs.version, '.0') }}
env:
RELEASE_BRANCH: ${{ needs.check-release-commit.outputs.release_branch }}
run: |
git checkout -b "$RELEASE_BRANCH"
git push origin "$RELEASE_BRANCH"
# When v0.50.0 is released, a release branch "release/v0.50" is created.
- name: Create release branch for patch versions
if: ${{ endsWith(needs.check-release-commit.outputs.version, '.0') }} # Skip patch versions
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }} # Should not trigger the workflow again
script: |
const releaseBranch = '${{ needs.check-release-commit.outputs.release_branch }}';
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/heads/${releaseBranch}`,
sha: '${{ needs.check-release-commit.outputs.release_sha }}'
});
# Add release branch to rulesets to enable merge queue
- name: Add release branch to rulesets
Expand Down

0 comments on commit dcfe145

Please sign in to comment.