Skip to content

Ensure CoinGecko API key is set #582

Ensure CoinGecko API key is set

Ensure CoinGecko API key is set #582

Workflow file for this run

name: Hotfix Release
permissions:
contents: write
on:
pull_request_target:
types: [closed]
branches:
- main
jobs:
hotfix_release:
if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'hotfix') }}
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: "${{ secrets.HOTFIX_ACTION_TOKEN }}"
fetch-depth: 0
- name: Configure git
run: |
git config user.name 'github-actions-bot'
git config user.email '[email protected]'
git fetch --tags
- name: Get latest release version tag
id: fetch_tag
run: |
LATEST_VERSION=$(curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r '.tag_name')
if ! [[ "$LATEST_VERSION" =~ ^v[0-9]+\.[0-9]+\..* ]]; then
echo "Invalid tag format, cannot bump version of: $LATEST_VERSION"
exit 1
fi
echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT
- name: Determine next patch version
id: bump
run: |
VERSION_NO_PREFIX="${VERSION#v}"
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION_NO_PREFIX"
NEW_PATCH=$((PATCH + 1))
NEW_TAG="v$MAJOR.$MINOR.$NEW_PATCH"
echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
env:
VERSION: ${{ steps.fetch_tag.outputs.latest }}
- name: Create and switch to hotfix branch
run: |
git checkout $LATEST
git checkout -b "hotfix/$BUMP"
env:
LATEST: ${{ steps.fetch_tag.outputs.latest }}
BUMP: ${{ steps.bump.outputs.tag }}
- name: Cherry-pick merged commit
run: |
if ! git cherry-pick "$MERGE_COMMIT_SHA"; then
echo "Cherry-pick failed. Please resolve conflicts manually."
exit 1
fi
env:
MERGE_COMMIT_SHA: ${{ github.event.pull_request.merge_commit_sha }}
- name: Create and push tag
id: tag_version
run: |
git tag $BUMP
git push origin $BUMP
env:
BUMP: ${{ steps.bump.outputs.tag }}
- name: "Create hotfix release"
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: "${{ secrets.HOTFIX_ACTION_TOKEN }}"
script: |
try {
const response = await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: `Hotfix ${process.env.BUMP}`,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.BUMP,
});
core.exportVariable('RELEASE_ID', response.data.id);
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}
env:
BUMP: ${{ steps.bump.outputs.tag }}