Skip to content

(release) v1.2.2

(release) v1.2.2 #5

Workflow file for this run

name: Create Release on PR
on:
pull_request:
types:
- closed
jobs:
create-release:
if: |
contains(github.event.pull_request.title, 'release') == true &&
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'master'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build Binary
run: |
go build monalize.go
ls -l
if: success()
- name: Extract Version
id: extract-version
run: |
# Use grep to find the first occurrence of the version number matching "## 0.0.0" pattern
version=$(grep -m 1 -oP '## \d+\.\d+\.\d+' CHANGELOG.md | cut -d ' ' -f 2)
echo "version=$version" >> $GITHUB_ENV
- name: Extract Changelog
id: extract-changelog
run: |
# Extract the content between the last two version headers
changelog=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+/{if (!version) {version=$0; next}} /^## [0-9]+\.[0-9]+\.[0-9]+/{exit} {if (version) description = description ORS $0} END {if (version) print description}' CHANGELOG.md | sed -e '/^## [0-9]+\.[0-9]+\.[0-9]+/d; s/^# //' > changelog.txt)
echo "changelog_file=changelog.txt" >> $GITHUB_ENV
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.version }}
release_name: ${{ env.version }}
body_path: ${{ env.changelog_file }}
draft: false
prerelease: false
- name: Get the upload URL
id: get_upload_url
run: echo "release_upload_url=${{ steps.create-release.outputs.upload_url }}" >> $GITHUB_ENV
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.release_upload_url }}
asset_path: ./monalize
asset_name: monalize
asset_content_type: application/octet-stream