Skip to content

Commit

Permalink
Release/CI enhancements (#247)
Browse files Browse the repository at this point in the history
* test new feature

* README instructions

* test release

* test tag

* v

* echo

* .

* .

* without v

* final for release

* testing patch versioning

* generate new release

* final version

* reference branch name from PR not main
  • Loading branch information
laysabit authored May 31, 2024
1 parent d741725 commit 71e6cb4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
42 changes: 35 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Release Drafter and Publisher

on:
push:
tags:
- v*
pull_request:
types: [closed]

permissions:
contents: read

jobs:
new_release:
if: github.event.pull_request.merged == true
permissions:
# write permission is required to create a github release
contents: write
Expand All @@ -21,17 +21,45 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Get branch name
id: getbranch
run: echo ::set-output name=BRANCH::${GITHUB_HEAD_REF}

# ${{ github.ref }} was not giving v* as tag name, but refs/tags/v* instead, so I had to abbreviate it
# ${{ github.ref }} was not giving v* as tag name, but refs/tags/v* instead, so It had to be abbreviated
- name: Get latest abbreviated tag
id: gettag
run: echo ::set-output name=TAG::$(git describe --tags --abbrev=7)
run: echo ::set-output name=TAG::$(git describe --tags --abbrev=0)

- name: Calculate next version
id: nextversion
run: |
BRANCH_NAME="${{ steps.getbranch.outputs.BRANCH }}"
CURRENT_VERSION="${{ steps.gettag.outputs.TAG }}"
CURRENT_VERSION="${CURRENT_VERSION#v}" # Remove the 'v' from the start of the version
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
if [[ $BRANCH_NAME =~ ^feature/ ]]; then
VERSION_PARTS[1]=$((VERSION_PARTS[1] + 1))
elif [[ $BRANCH_NAME =~ ^patch/ ]]; then
VERSION_PARTS[2]=$((VERSION_PARTS[2] + 1))
elif [[ $BRANCH_NAME =~ ^release/ ]]; then
VERSION_PARTS[0]=$((VERSION_PARTS[0] + 1))
fi
NEXT_VERSION="v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
echo ::set-output name=NEXT_VERSION::"$NEXT_VERSION"
- name: Create and publish new tag
run: |
git tag ${{ steps.nextversion.outputs.NEXT_VERSION }}
git push origin ${{ steps.nextversion.outputs.NEXT_VERSION }}
- uses: release-drafter/release-drafter@v5
with:
commitish: master
name: "stellar-etl ${{ steps.gettag.outputs.TAG }}"
tag: ${{ github.ref }}
name: "stellar-etl ${{ steps.nextversion.outputs.NEXT_VERSION }}"
tag: ${{ steps.nextversion.outputs.NEXT_VERSION }}
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

The Stellar-ETL is a data pipeline that allows users to extract data from the history of the Stellar network.

## ** Before creating a branch **

Pay attention, it is very important to know if your modification to this repository is a release (breaking changes), a feature (functionalities) or a patch(to fix bugs). With that information, create your branch name like this:

* ```release/<branch-name>```
* ```feature/<branch-name>```
* ```patch/<branch-name>```

If branch is already made, just rename it *before passing the pull request*.

## **Table of Contents**

- [Exporting the Ledger Chain](#exporting-the-ledger-chain)
Expand Down

0 comments on commit 71e6cb4

Please sign in to comment.