Skip to content

Commit

Permalink
Merge pull request #7 from epam/ci/add-github-workflow
Browse files Browse the repository at this point in the history
Added CI workflow
  • Loading branch information
Sinyuk authored Sep 25, 2024
2 parents 08f50e2 + 0238074 commit 3a7be25
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI

on:
push:
branches:
- main

jobs:
Release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write

env:
CHANGELOG_FILE: "CHANGELOG.md"

steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Get version
id: get_version
run: |
RELEASE_VERSION=$(cat modular_api/version.py | awk -F"__version__ =" {'print $2'} | sed -e 's|["'\'' '^',]||g' | xargs)
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
echo "release_version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
echo "Name ${{ github.ref_name }}. Version $RELEASE_VERSION"
- name: Fetching previous version
id: get_previous_version
run: |
git fetch --tags
PREVIOUS_VERSION=$(git tag --sort=-creatordate | sed -n '2p' | sed 's/^v//')
echo "PREVIOUS_VERSION=$PREVIOUS_VERSION" >> $GITHUB_ENV
echo "previous_version=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
echo "Previous version: $PREVIOUS_VERSION"
- name: Fetching release notes
id: release_notes
run: |
extract_release_notes() {
changelog_file=$1
current_version=$2
previous_version=$3
# Escape dots in version for regex
current_version_escaped=$(echo "$current_version" | sed 's/\./\\./g')
previous_version_escaped=$(echo "$previous_version" | sed 's/\./\\./g')
# Extract release notes
release_notes=$(awk "/## \[$current_version_escaped\]/,/## \[$previous_version_escaped\]/" "$changelog_file" | sed '$d')
echo "$release_notes"
}
RELEASE_NOTES=$(extract_release_notes ${{ env.CHANGELOG_FILE }} ${{ steps.get_version.outputs.release_version }} ${{ steps.get_previous_version.outputs.previous_version }})
echo "Release notes:"
echo "$RELEASE_NOTES"
echo "$RELEASE_NOTES" > release_notes.md
- name: Create tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.get_version.outputs.release_version }}',
sha: context.sha
})
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.release_version }}
name: ${{ steps.get_version.outputs.release_version }}
body_path: release_notes.md
prerelease: false
draft: false
make_latest: true

0 comments on commit 3a7be25

Please sign in to comment.