Skip to content

Instantly share code, notes, and snippets.

@vzool
Forked from youhide/build.yml
Created August 1, 2024 07:10
Show Gist options
  • Save vzool/0c229646941bd68ce392e1d7d2b12b4c to your computer and use it in GitHub Desktop.
Save vzool/0c229646941bd68ce392e1d7d2b12b4c to your computer and use it in GitHub Desktop.
GitHub Actions - Build for Windows, MacOS, Linux and release on tag.
name: Node CI
on:
push:
tags:
- 'v*'
jobs:
upload-release:
runs-on: ubuntu-18.04
needs: [build-macos, build-linux, build-windows]
steps:
- uses: actions/checkout@v1
- name: create release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: download artifacts
uses: actions/download-artifact@v1
with:
name: uploads
- name: upload macos
id: upload-macos
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./uploads/macos.zip
asset_name: macos.zip
asset_content_type: application/zip
- name: upload linux
id: upload-linux
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./uploads/linux.zip
asset_name: linux.zip
asset_content_type: application/zip
- name: upload windows
id: upload-windows
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./uploads/windows.zip
asset_name: windows.zip
asset_content_type: application/zip
build-macos:
runs-on: macOS-10.14
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm ci
npm test
- name: npm run build
run: |
npm run build
- name: zip macos artifact
run: |
zip -r macos out
- name: upload macos artifact
uses: actions/upload-artifact@v1
with:
name: uploads
path: macos.zip
build-linux:
runs-on: ubuntu-18.04
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm ci
npm test
- name: npm run build
run: |
npm run build
- name: zip linux artifact
run: |
zip -r linux out
- name: upload linux artifact
uses: actions/upload-artifact@v1
with:
name: uploads
path: linux.zip
build-windows:
runs-on: windows-2019
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm ci
npm test
- name: npm run build
run: |
npm run build
- name: zip win artifact
run: |
powershell Compress-Archive out windows.zip
- name: upload windows artifact
uses: actions/upload-artifact@v1
with:
name: uploads
path: windows.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment