Skip to content

Merge pull request #15 from codeboxrcodehub/dev #10

Merge pull request #15 from codeboxrcodehub/dev

Merge pull request #15 from codeboxrcodehub/dev #10

Workflow file for this run

name: Create Release
on:
push:
tags:
- '*.*.*' # Triggers on tags like 1.0.0
branches:
- master # Ensures it only runs on the master branch
jobs:
create_release:
if: github.ref == 'refs/heads/master' # Ensures the job runs only on master branch
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Read version from readme.txt
id: read_version
run: |
VERSION=$(grep -Eo 'Stable tag: [0-9]+\.[0-9]+\.[0-9]+' readme.txt | awk '{print $3}')
echo "plugin_version=$VERSION" >> $GITHUB_ENV
- name: Get latest tag
id: get_latest_tag
run: |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "latest_tag=$LATEST_TAG" >> $GITHUB_ENV
- name: Extract Changelog
id: extract_changelog
run: |
START_LINE=$(grep -n "== Changelog ==" readme.txt | cut -d : -f 1)
END_LINE=$(grep -n "= ${{ env.plugin_version }} =" readme.txt | cut -d : -f 1)
sed -n "${START_LINE},${END_LINE}p" readme.txt | sed '1d;$d' > CHANGELOG.txt
echo "changelog=$(cat CHANGELOG.txt)" >> $GITHUB_ENV
- name: Create zip file
run: |
REPO_NAME=$(basename `git rev-parse --show-toplevel`)
zip -r ${REPO_NAME}.zip . -x '*.git*' -x '*.github*' -x '*.distignore*'
echo "repo_name=${REPO_NAME}" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.latest_tag }}
release_name: "Release ${{ env.plugin_version }}"
body: ${{ env.changelog }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.repo_name }}.zip
asset_name: ${{ env.repo_name }}.zip
asset_content_type: application/zip