Skip to content

Commit

Permalink
Prepare for NPM (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti authored May 17, 2022
1 parent 906dead commit c226a8b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dev-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
- name: TGZ name
run: |
VERSION=$(jq -r '.version' < package.json)
echo "TGZ=dev-containers-cli-${VERSION}.tgz" | tee -a $GITHUB_ENV
echo "TGZ_UPLOAD=dev-containers-cli-${VERSION}-${GITHUB_SHA:0:8}.tgz" | tee -a $GITHUB_ENV
echo "TGZ=devcontainers-cli-${VERSION}.tgz" | tee -a $GITHUB_ENV
echo "TGZ_UPLOAD=devcontainers-cli-${VERSION}-${GITHUB_SHA:0:8}.tgz" | tee -a $GITHUB_ENV
- name: Store TGZ
uses: actions/upload-artifact@v2
with:
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/publish-dev-containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish @devcontainers/cli

on:
push:
tags:
- 'v*'

jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
scope: '@devcontainers'
- name: Verify Versions
run: |
node -e "
const packageRef = 'refs/tags/v' + require('./package.json').version;
const githubRef = '${{ github.ref }}';
if (packageRef !== githubRef && packageRef + '-pre-release' != githubRef) {
console.log('::error::' + 'Version Mismatch.', packageRef, githubRef);
throw Error('Version Mismatch');
}
"
- name: TGZ name
run: |
VERSION=$(jq -r '.version' < package.json)
echo "TGZ=devcontainers-cli-${VERSION}.tgz" | tee -a $GITHUB_ENV
echo "TGZ_UPLOAD=devcontainers-cli-${VERSION}-${GITHUB_SHA:0:8}.tgz" | tee -a $GITHUB_ENV
- name: Download TGZ
uses: dawidd6/action-download-artifact@6f8f427fb41886a66b82ea11a5a15d1454c79415
with:
workflow: dev-containers.yml
workflow_conclusion: success
commit: ${{ github.sha }}
name: ${{ env.TGZ_UPLOAD }}
path: .
- name: Publish TGZ
run: npm publish ${TGZ} --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "dev-containers-cli",
"name": "@devcontainers/cli",
"description": "Dev Containers CLI",
"version": "0.1.0",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion src/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Dev Containers CLI', function () {
before('Install', async () => {
await shellExec(`rm -rf ${tmp}/node_modules`);
await shellExec(`mkdir -p ${tmp}`);
await shellExec(`npm --prefix ${tmp} install dev-containers-cli-${pkg.version}.tgz`);
await shellExec(`npm --prefix ${tmp} install devcontainers-cli-${pkg.version}.tgz`);
});

it('Global --help', async () => {
Expand Down

0 comments on commit c226a8b

Please sign in to comment.