Skip to content

Commit 8df0fba

Browse files
author
Roland Peelen
committed
🔖 - Build Release Mechanism
1 parent 5549c5f commit 8df0fba

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed

.github/workflows/build.yml

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
uses: styfle/[email protected]
1414
with:
1515
access_token: ${{ github.token }}
16-
release:
16+
build:
1717
name: Release ${{ matrix.os }}
1818
strategy:
1919
fail-fast: false
@@ -34,7 +34,21 @@ jobs:
3434
with:
3535
command: build
3636
args: --release
37-
- name: Upload Mac / Linus Binaries to release
37+
- name: Upload Mac / Linux Binaries
38+
if: ${{ matrix.os != 'windows-latest' }}
39+
uses: actions/upload-artifact@v2
40+
with:
41+
name: ${{ matrix.os }}
42+
path: target/release/rewatch
43+
retention-days: 1
44+
- name: Upload Windows Binaries
45+
if: ${{ matrix.os == 'windows-latest' }}
46+
uses: actions/upload-artifact@v2
47+
with:
48+
name: ${{ matrix.os }}
49+
path: target/release/rewatch.exe
50+
retention-days: 1
51+
- name: Attach Mac / Linux Binaries to release
3852
if: ${{ matrix.os != 'windows-latest' }}
3953
uses: svenstaro/upload-release-action@v2
4054
with:
@@ -43,12 +57,44 @@ jobs:
4357
asset_name: rewatch-${{ matrix.os }}
4458
tag: ${{ github.ref }}
4559
overwrite: true
46-
- name: Upload Windows Binaries to release
47-
if: ${{ matrix.os != 'windows-latest' }}
60+
- name: Attach Windows Binaries to release
61+
if: ${{ matrix.os == 'windows-latest' }}
4862
uses: svenstaro/upload-release-action@v2
4963
with:
5064
repo_token: ${{ secrets.GITHUB_TOKEN }}
5165
file: target/release/rewatch.exe
5266
asset_name: rewatch-${{ matrix.os }}
5367
tag: ${{ github.ref }}
5468
overwrite: true
69+
70+
npm-release:
71+
name: NPM Release
72+
runs-on: ubuntu-latest
73+
if: github.event.action == 'published'
74+
needs:
75+
- build
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v2
79+
with:
80+
ref: ${{ github.ref }}
81+
82+
- name: Download Artifacts
83+
uses: actions/download-artifact@v2
84+
85+
- name: Move / Rename Artifacts
86+
run: |
87+
mv ubuntu-latest/rewatch ./rewatch-linux
88+
mv macos-latest/rewatch ./rewatch-macos
89+
mv windows-latest/rewatch.exe ./rewatch-windows.exe
90+
91+
- uses: actions/setup-node@v1
92+
with:
93+
always-auth: true
94+
registry-url: "https://registry.npmjs.org"
95+
96+
- env:
97+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
98+
run: |
99+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
100+
yarn publish

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "@rolandpeelen/rewatch",
3+
"version": "0.0.4",
4+
"license": "BSD-3-Clause",
5+
"files": [
6+
"/rewatch",
7+
"/rewatch.cmd",
8+
"/rewatch-linux.exe",
9+
"/rewatch-macos.exe",
10+
"/rewatch-windows.exe"
11+
]
12+
}

rewatch

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env sh
2+
3+
# Get the directory of the script to work from.
4+
DIR=$(dirname "$0")
5+
6+
if [ "$(uname)" = "Darwin" ]; then
7+
# Run the Mac Version
8+
$DIR/rewatch-macos.exe $@
9+
elif [ "$(expr substr $(uname -s) 1 5)" = "Linux" ]; then
10+
# Run the Linux Version
11+
$DIR/rewatch-linux.exe $@
12+
else
13+
echo "No release available for '$(uname)'"
14+
exit 1
15+
fi

rewatch.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
REM no need to branch on OS here, it will only be used on windows
3+
%~dp0\rewatch-windows.exe %*

0 commit comments

Comments
 (0)