66 lines
1.9 KiB
YAML
66 lines
1.9 KiB
YAML
name: Tag version
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
bump:
|
|
description: "Which part to bump?"
|
|
required: true
|
|
default: "patch"
|
|
type: choice
|
|
options:
|
|
- major
|
|
- minor
|
|
- patch
|
|
|
|
jobs:
|
|
tag:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Configure git
|
|
run: |
|
|
echo "${{ secrets.CI_BOT_GPG_PRIVATE_KEY }}" | gpg --import --batch --yes
|
|
# set trust non-interactively
|
|
echo "$GPG_KEY_ID:5:" | gpg --import-ownertrust
|
|
git config --global user.signingkey $GPG_KEY_ID
|
|
git config --global commit.gpgSign true
|
|
git config --global tag.gpgSign true
|
|
git config user.name "Gitea CI"
|
|
git config user.email "gitea-ci@hq.egothor.org"
|
|
git remote set-url origin https://ci-bot:${GITEA_PUSH_TOKEN}@gitea.egothor.org/Egothor/conflux.git
|
|
env:
|
|
GITEA_PUSH_TOKEN: ${{ secrets.CI_PUSH_TOKEN }}
|
|
GPG_KEY_ID: ${{ secrets.CI_BOT_GPG_KEY_ID }}
|
|
|
|
- name: Bump version and tag
|
|
run: |
|
|
latest=$(git tag --list 'conflux@*' | sed 's/conflux@//' | sort -V | tail -n 1)
|
|
if [[ -z "$latest" ]]; then
|
|
latest="0.0.0"
|
|
fi
|
|
echo "Latest: $latest"
|
|
IFS='.' read -r major minor patch <<<"$latest"
|
|
case "${{ github.event.inputs.bump }}" in
|
|
major)
|
|
major=$((major+1)); minor=0; patch=0 ;;
|
|
minor)
|
|
minor=$((minor+1)); patch=0 ;;
|
|
patch)
|
|
patch=$((patch+1)) ;;
|
|
*)
|
|
echo "Invalid bump type"
|
|
exit 1
|
|
;;
|
|
esac
|
|
next="$major.$minor.$patch"
|
|
new_tag="conflux@$next"
|
|
git tag -s $new_tag -m "Release $new_tag"
|
|
git push origin $new_tag
|
|
echo "Tagged $new_tag"
|