Skip to content

Commit

Permalink
Migrate from travis to github actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
wparad committed Nov 4, 2021
1 parent d43336a commit e7c192e
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 31 deletions.
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

33 changes: 25 additions & 8 deletions make.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,31 @@
let commander = require('commander');
let fs = require('fs-extra');

let travis = require('travis-build-tools')(process.env.GIT_TAG_PUSHER);
let version = travis.GetVersion();
// const githubActionsRunner = require('ci-build-tools')(process.env.GITHUB_TOKEN);
function getVersion() {
let release_version = '0.0';
const pull_request = '';
const branch = process.env.GITHUB_REF;
const build_number = process.env.GITHUB_RUN_NUMBER;

//Builds of pull requests
if (pull_request && !pull_request.match(/false/i)) {
release_version = `0.${pull_request}`;
} else if (!branch || !branch.match(/^(refs\/heads\/)?release[/-]/i)) {
//Builds of branches that aren't master or release
release_version = '0.0';
} else {
//Builds of release branches (or locally or on server)
release_version = branch.match(/^(?:refs\/heads\/)?release[/-](\d+(?:\.\d+){0,3})$/i)[1];
}
return `${release_version}.${(build_number || '0')}.0.0.0.0`.split('.').slice(0, 3).join('.');
}
const version = getVersion();
commander.version(version);

/**
* Build
*/
* Build
*/
commander
.command('build')
.description('Setup require build files for npm package.')
Expand All @@ -24,17 +42,16 @@ commander
});

/**
* After Build
*/
* After Build
*/
commander
.command('after_build')
.description('Publishes git tags and reports failures.')
.action(() => {
let package_metadata = require('./package.json');
console.log('After build package %s (%s)', package_metadata.name, version);
console.log('');
travis.PublishGitTag();
travis.MergeDownstream('release/', 'master');
// githubActionsRunner.MergeDownstream('release/', 'main');
});

commander.on('*', () => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@typescript-eslint/parser": "^3.1.0",
"chai": "^4.2.0",
"check-dts": "^0.4.4",
"ci-build-tools": "^1.0.13",
"commander": "^4.0.1",
"eslint": "^7.2.0",
"eslint-config-cimpress-atsquad": "^1.0.67",
Expand Down
46 changes: 46 additions & 0 deletions workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
push:
branches:
- main
- master
- 'release/**'
pull_request:
branches:
- main
- master
- 'release/**'

jobs:
build:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12.21.0
registry-url: 'https://registry.npmjs.org'

- name: Install packages
run: npm install
- name: Run build
run: node make.js build
- name: Test
run: yarn lint && yarn test
- name: Deploy to NPM
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.event_name == 'push'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}

- name: After build
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node make.js after_build
- name: Create Github Release and Tag
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.event_name == 'push'
run: |
git tag ${GITHUB_REF/refs\/heads\/release\//}.$GITHUB_RUN_NUMBER
git push origin ${GITHUB_REF/refs\/heads\/release\//}.$GITHUB_RUN_NUMBER
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,13 @@ [email protected]:
optionalDependencies:
fsevents "~2.1.1"

ci-build-tools@^1.0.13:
version "1.0.13"
resolved "https://registry.yarnpkg.com/ci-build-tools/-/ci-build-tools-1.0.13.tgz#5c63e99d088a3052e06c2a07ebede586bd14cffc"
integrity sha1-XGPpnQiKMFLgbCoH6+3lhr0Uz/w=
dependencies:
semver "^5.0.3"

ci-job-number@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/ci-job-number/-/ci-job-number-1.2.2.tgz#f4e5918fcaeeda95b604f214be7d7d4a961fe0c0"
Expand Down

0 comments on commit e7c192e

Please sign in to comment.