Skip to content

Commit

Permalink
add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
soymadip committed Oct 17, 2024
1 parent 5d42907 commit f91d8ed
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release on Version Change

on:
push:
paths:
- '.version'

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Read version
id: get_version
run: echo "VERSION=$(cat .version)" >> $GITHUB_ENV

- name: Determine if it's a pre-release
id: pre_release_check
run: |
if [[ "${{ env.VERSION }}" == 0* ]]; then
echo "PRE_RELEASE=true" >> $GITHUB_ENV
echo "RELEASE_NAME=${{ env.VERSION }}-alpha" >> $GITHUB_ENV
else
echo "PRE_RELEASE=false" >> $GITHUB_ENV
echo "RELEASE_NAME=${{ env.VERSION }}" >> $GITHUB_ENV
fi
- name: Get repository name
id: get_repo_name
run: echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV

- name: Create a tar.gz archive
run: |
mkdir release
rsync -av --progress . ./release --exclude=".git" --exclude=".github" --exclude="TODO.md" --exclude="README.md"
tar -czvf ./${{ env.REPO_NAME }}.tar.gz -C release .
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
body: "version: ${{ env.VERSION }}."
prerelease: ${{ env.PRE_RELEASE }}
name: ${{ env.RELEASE_NAME }}
files: "${{ env.REPO_NAME }}.tar.gz"
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}

- name: Generate changelog from commits
id: generate_changelog
run: |
CHANGELOG=$(git log -1 --pretty=%B | tr -d '\n' | sed 's/"/\\"/g')
echo "CHANGELOG=${CHANGELOG}" >> $GITHUB_ENV
- name: Update release with changelog
run: |
gh release edit ${{ env.VERSION }} --notes "${{ env.CHANGELOG }}"
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}

0 comments on commit f91d8ed

Please sign in to comment.