Skip to content

Commit

Permalink
👷 Added Release Workflow (#2)
Browse files Browse the repository at this point in the history
* Added automatic version bump / release

* Added  npm publish + tests/build

* Update release action

* Update build process, whitelist npm package files

* Rename file

* Clean up release script

* Merged build and publish

Co-authored-by: Regan Karlewicz <regan@econify.com>
Co-authored-by: craigfay <craigfay1@gmail.com>
  • Loading branch information
3 people committed May 31, 2022
1 parent d5e55b5 commit 0f02856
Showing 1 changed file with 103 additions and 34 deletions.
137 changes: 103 additions & 34 deletions .github/workflows/release_npm_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,150 @@ name: Release NPM Package

on:
workflow_dispatch:
release:
types:
- created
inputs:
release_type:
description: "Release type (minor, major, patch):"
required: true
default: patch

jobs:
build_ubuntu:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1

- name: Build
run: cd distill && cargo build --release
- name: Rename Binary
run: mv distill/target/release/distill distill-for-ubuntu

- name: Upload Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: distill-for-ubuntu
path: dist/
name: ubuntu
path: target/release/distill

build_macos:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1

- name: Build
run: cd distill && cargo build --release
- name: Rename Binary
run: mv distill/target/release/distill distill-for-osx

- name: Upload Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: distill-for-osx
path: dist/
name: osx
path: target/release/distill

build_windows:
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1

- name: Build
run: cd distill && cargo build --release
- name: Rename Binary
run: mv distill/target/release/distill.exe distill-for-windows.exe

- name: Upload Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: distill-for-windows.exe
path: dist/
name: windows
path: target/release/distill.exe

publish_npm_package:
needs: [build_ubuntu, build_macos, build_windows]
runs-on: ubuntu-18.04
build_and_publish_bundle:
name: Create Release
runs-on: ubuntu-latest
needs:
- build_ubuntu
- build_macos
- build_windows
outputs:
NEW_TAG: ${{ steps.version.outputs.NEW_TAG }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Checkout
uses: actions/checkout@v3
with:
node-version: "16"
- uses: actions/download-artifact@v2
fetch-depth: 0

# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Run Linter
run: yarn run lint

- name: Run Unit Tests
run: yarn run test

- name: Run package
run: yarn run build

- name: Download Binaries
uses: actions/download-artifact@v3
with:
path: temp_dist

- name: Flatten Binary Directory
run: |
mkdir dist
mv temp_dist/**/* dist || true
rmdir dist/**/* || true
rm -rf temp_dist
- name: Grant Permissions
run: chmod +x dist/*
- name: Setup Package Registry Credentials
run: echo "not necessary yet!"
- name: Preview Publish
run: npm pack
run: chmod +x dist/**/*

# - name: Preview Publish
# run: npm pack

- name: List Dir
run: ls -R

- name: Automated Version Bump
uses: phips28/gh-action-bump-version@master
id: version_bump
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target-branch: ${{ env.GIT_REF }}
default: ${{ github.event.inputs.release_type }}
minor-wording: "feature,MAGWEB"
major-wording: "BREAKING"
patch-wording: "hotfix,HOTFIX"
commit-message: "CI: version bump to {{version}} [skip ci]"
tag-prefix: "v"

- name: Create Changelog
id: changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: gandarez/changelog-action@v1.2.0
with:
exclude: |
^CI: version bump to.*
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.version_bump.outputs.newTag }}
name: ${{ steps.version_bump.outputs.newTag }}
body: ${{ steps.changelog.outputs.changelog }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Package
run: echo "not necessary yet!"
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 0f02856

Please sign in to comment.