Skip to content

Commit

Permalink
Merge pull request #3 from stickerum/build-workflow
Browse files Browse the repository at this point in the history
Update lock file, add workflow
  • Loading branch information
talyguryn authored Apr 15, 2021
2 parents 135c883 + 4a36bd8 commit f88becc
Show file tree
Hide file tree
Showing 4 changed files with 1,635 additions and 1,540 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Create a release

on:
pull_request:
branches:
- master
types: [closed]

jobs:
# If pull request was merged then we should check for a package version update
check-version-changing:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
# Checkout to target branch
- uses: actions/checkout@v2
with:
fetch-depth: 0

# Get package new version name
- name: Get package info
id: packageNew
uses: codex-team/action-nodejs-package-info@v1

# Checkout to the base commit before merge
- name: Checkout to the base commit before merge
run: git checkout ${{ github.event.pull_request.base.sha }}

# Get package old version name
- name: Get package info
id: packageOld
uses: codex-team/action-nodejs-package-info@v1

# Stop workflow if version was not changed
- name: Stop workflow if version was not changed
uses: actions/github-script@v3
if: steps.packageOld.outputs.version == steps.packageNew.outputs.version
with:
script: |
core.setFailed('No version changes. ${{ steps.packageOld.outputs.version }}')
# Create a new draft release
release-draft:
needs: check-version-changing
runs-on: ubuntu-latest
steps:
# Checkout to target branch
- uses: actions/checkout@v2

# Setup node environment
- uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://registry.npmjs.org/

# Prepare, build and publish project
- name: Install dependencies
run: yarn

# Pack the app
- name: Build output files
run: yarn pack-app

# Get package version name
- name: Get package info
id: package
uses: codex-team/action-nodejs-package-info@v1

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package.outputs.version }}
release_name: v${{ steps.package.outputs.version }}

# Fill release description from pull request body name
body: "${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}"

# If version name contains "-rc" suffix than mark a "pre-release" checkbox
prerelease: ${{ contains(steps.package.outputs.version, '-rc') }}

# Upload
- 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: build/contourer-macos
asset_name: contourer-macos
asset_content_type: application/octet-stream


- 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: build/contourer-linux
asset_name: contourer-linux
asset_content_type: application/octet-stream


- 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: build/contourer-win.exe
asset_name: contourer-win.exe
asset_content_type: application/octet-stream
Loading

0 comments on commit f88becc

Please sign in to comment.