Skip to content

Commit

Permalink
Merge pull request #36 from mitoc/mprat/buildartifact
Browse files Browse the repository at this point in the history
Release build/ directory on merge to main
  • Loading branch information
mprat authored Jun 10, 2022
2 parents 55a3224 + bf747c8 commit b84ac0f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 9 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Release a new build on push to main.
# This will also get triggered after each PR is merged against main

name: Release

on:
push:
branches: [ main ]

jobs:
release:
# do all the steps from the CI workflow
# but also do the release step
uses: ./.github/workflows/yarn.yml
with:
release: true
56 changes: 48 additions & 8 deletions .github/workflows/yarn.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI
name: Yarn CI & CD

on:
push:
branches: [ main ]
# runs on all pull requests against main
pull_request:
branches: [ main ]
workflow_call:
inputs:
release:
required: false
type: boolean

jobs:
build:

runs-on: ubuntu-latest

runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

outputs:
sha_short: ${{ steps.vars.outputs.sha_short }}

steps:
- uses: actions/checkout@v3
Expand All @@ -27,10 +32,45 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install production-level yarn dependencies
uses: Borales/actions-yarn@v2.3.0
uses: Borales/actions-yarn@v3.0.0
with:
cmd: install --frozen-lockfile --production
- name: Build output for prod
uses: Borales/actions-yarn@v2.3.0
uses: Borales/actions-yarn@v3.0.0
with:
cmd: build
- name: tar files together before artifact creation
run: tar -cvf build.tar build/
- name: Upload build.zip artifact for release
uses: actions/upload-artifact@v3
with:
name: build
path: build.tar
- name: Set variables for tag generation
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"

# CD-specific job
release:
if: ${{ inputs.release }}
needs: build

runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [16.x]

steps:
- name: Download artifact from build
uses: actions/download-artifact@v3
with:
name: build
- name: Generate release
uses: ncipollo/release-action@v1
with:
allowUpdates: false
artifactErrorsFailBuild: true
artifacts: "build.tar"
# don't use {{ github.sha }} here since that's the full SHA
tag: 1.0.0-${{ needs.build.outputs.sha_short }}
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mitoc-gear-ui",
"version": "0.1.0",
"version": "1.0.0",
"private": true,
"dependencies": {
"@eslint/eslintrc": "^1.2.1",
Expand Down

0 comments on commit b84ac0f

Please sign in to comment.