Skip to content

Commit

Permalink
✨ Autoreleasing GH Action
Browse files Browse the repository at this point in the history
  • Loading branch information
fiendish committed May 19, 2020
1 parent 8f6eace commit 6ee1ddd
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/gh_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow will install Python dependencies, run pre-release script, and
# then bundle a github release

name: Release generator

on:
pull_request:
types:
- closed

jobs:
context:
if: github.base_ref == 'master' && github.event.pull_request.merged && contains( github.event.pull_request.labels.*.name, 'release')
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Create tag from title and run asset script
id: find_tag_and_prepare_assets
run: |
TAG=$(echo ${{ github.event.pull_request.title }} | sed -E "s/^.*Release (.+\..+\..+)$/\1/g")
echo "::set-output name=tag::$TAG"
SCRIPT=.github/prepare_assets.sh
if [ -f $SCRIPT ]; then
chmod u+x $SCRIPT
$SCRIPT
fi
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.find_tag_and_prepare_assets.outputs.tag }}
release_name: ${{ github.event.pull_request.title }}
body: ${{ github.event.pull_request.body }}
draft: false
prerelease: false

- name: Upload Assets
run: |
upload_url=${{ steps.create_release.outputs.upload_url }}
if [ -f .github/release_assets.txt ]; then
while IFS="" read -r FILE || [ -n "$FILE" ]
do
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary "@$FILE" \
"${upload_url%\{*}?name=$(basename $FILE)"
done < .github/release_assets.txt
fi
59 changes: 59 additions & 0 deletions github_action/gh_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow will load Python, run a pre-release script to generate assets,
# and then bundle a github release

name: Release generator

on:
pull_request:
types:
- closed

jobs:
context:
if: github.base_ref == 'master' && github.event.pull_request.merged && contains( github.event.pull_request.labels.*.name, 'release')
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Create tag from title and run asset script
id: find_tag_and_prepare_assets
run: |
TAG=$(echo ${{ github.event.pull_request.title }} | sed -E "s/^.*Release (.+\..+\..+)$/\1/g")
echo "::set-output name=tag::$TAG"
SCRIPT=.github/prepare_assets.sh
if [ -f $SCRIPT ]; then
chmod u+x $SCRIPT
$SCRIPT
fi
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.find_tag_and_prepare_assets.outputs.tag }}
release_name: ${{ github.event.pull_request.title }}
body: ${{ github.event.pull_request.body }}
draft: false
prerelease: false

- name: Upload Assets
run: |
upload_url=${{ steps.create_release.outputs.upload_url }}
if [ -f .github/release_assets.txt ]; then
while IFS="" read -r FILE || [ -n "$FILE" ]
do
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary "@$FILE" \
"${upload_url%\{*}?name=$(basename $FILE)"
done < .github/release_assets.txt
fi

0 comments on commit 6ee1ddd

Please sign in to comment.