Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert from travis to GitHub actions #284

Merged
merged 7 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ updates:
assignees:
- jsnoble
- godber
- busma13
- sotojn
ignore:
- dependency-name: '@types/node'
versions:
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build and Publish

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

jobs:
npm-publish:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
# NOTE: Hard Coded Node Version
node-version: '18.19.1'
registry-url: 'https://registry.npmjs.org'
- run: yarn setup
- run: ./scripts/publish.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets discuss whether we really need a separate publish.sh or should we do a more standard workflow like:

https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work. I just need to pass in the new version or yarn publish will try to bump it.

env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48 changes: 48 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Fetch-Github-Release Tests
on:
pull_request:
branches: [ master ]

jobs:
verify-build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.19.1
cache: 'yarn'

- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"

- name: Lint codebase
run: yarn lint

run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.19.1, 20.11.1, 22.1.0]
busma13 marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"

- name: Test
run: yarn --silent test
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
A node module to download Github release assets. It will also uncompress zip
files and skip downloading if a file already exists.

[![Build Status](https://travis-ci.org/terascope/fetch-github-release.svg?branch=master)](https://travis-ci.org/terascope/fetch-github-release)
[![codecov](https://codecov.io/gh/terascope/fetch-github-release/branch/master/graph/badge.svg)](https://codecov.io/gh/terascope/fetch-github-release)
[![Build Status](https://david-dm.org/terascope/fetch-github-release.svg)](https://david-dm.org/terascope/fetch-github-release)

```
$ fetch-github-release -s darwin-x64 electron electron
Downloading electron/[email protected]...
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "0.8.7",
"version": "0.8.8",
"description": "Download a specific release from github",
"files": [
"dist/src/**/*",
Expand Down
59 changes: 59 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -e

check_deps() {
if [ -z "$(command -v jq)" ]; then
echo "./publish.sh requires jq installed"
exit 1
fi
}

publish() {
local dryRun="$1"
local name tag targetVersion currentVersion isPrivate

name="$(jq -r '.name' package.json)"
isPrivate="$(jq -r '.private' package.json)"
if [ "$isPrivate" == 'true' ]; then
echo "* $name is a private module skipping..."
return;
fi

targetVersion="$(jq -r '.version' package.json)"
currentVersion="$(npm info --json 2> /dev/null | jq -r 'first(.[]) | .version // "0.0.0"')"

if [ "$currentVersion" != "$targetVersion" ]; then
echo "Publishing:"
echo " $name@$currentVersion -> $targetVersion"
if [ "$dryRun" == "false" ]; then
yarn publish \
--silent \
--tag "$tag" \
--non-interactive \
--new-version "$targetVersion" \
--no-git-tag-version
fi
else
echo "Not publishing:"
echo " $name@$currentVersion = $targetVersion"
fi
}

main() {
check_deps
local projectDir dryRun='false'

if [ "$1" == '--dry-run' ]; then
dryRun='true'
fi

projectDir="$(pwd)"

echo "Check NPM Authentication"
npm whoami

publish "$dryRun";
}

main "$@"
22 changes: 14 additions & 8 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,17 @@ function filterAsset(asset: GithubReleaseAsset): boolean {
return new RegExp(command.search).test(asset.name);
}

downloadRelease(user as string, repo as string, outputdir as string, filterRelease, filterAsset,
!!command.zipped, !!command.quiet)
.catch((err) => {
console.error(err);
process.exitCode = 1;
}).finally(() => {
process.exit();
});
downloadRelease(
user as string,
repo as string,
outputdir as string,
filterRelease,
filterAsset,
!!command.zipped,
!!command.quiet
).catch((err) => {
console.error(err);
process.exitCode = 1;
}).finally(() => {
process.exit();
});
Loading