Skip to content

Commit

Permalink
Release publish NPM packages (#126)
Browse files Browse the repository at this point in the history
* chore: renamed build-and-test to build-binaries

* chore: add npm build packages

* chore: added npm scripts and publish jobs

* chore: fixed duplicate job ids

* chore: moved update package.json to npm script

* chore: added plugin list outputs

* chore: added plugin variable to update commad

* chore: added node actions to release

* chore: added checkout to release

* chore: moved checkout and changed conditions for publish

* chore: changed suffix output

* chore: added --registry to npm publish

* chore: added node token

* chore: fixed npm publish command

* chore: seperate npm publish from release

* chore: seperate npm publish from release

* chore: removed teztnets

* chore: removed flextesa

* chore: removed redundant build job

* chore: try npm version

* chore: try npm version

* chore: try npm version

* chore: try npm version

* chore: added access to public

* chore: npm publish jobs

* chore: added global env variables

* chore: changed scope to taqueria

* chore: changed tag for PR

* chore: changed tag for PR

* chore: updated website packages

* chore: changed binary name to taq

* chore: removed custom npm scripts

* chore: removed windows and mac binaries until merge

* chore: try merge comment jobs in one

* chore: try merge comment jobs in one

* chore: cleanup environment variables

* chore: change npm version

* chore: change npm version

* chore: GITHUB_SHA env expression

* chore: short sha in javascript

* chore: short sha in javascript

* chore: fix comment tag

* chore: add line break

* chore: add line break

* Automatically run npm install before running npm run build

* Update .gitignore for vscode-extension

* Update .gitignore

* Taqueria vscode initial commit

* Initial init command

* Rebase branch on latest changes from main

* VSCode Extension pipeline for testing, building, and publishing

* fix string interpolation

* set default working-directory

* Fix typo on output

* remove working-dir default

* add file extension

* chore: update README warning

* Publish VSCode Extension to the Marketplace (#142)

* Fix publishing job for VSCode Extension

* Trigger workflow only if vscode extension code is changed

* chore: publish next and latest if release is published

* chore: fixed next check

* chore: fixed package-lock.json for protocol

* chore: using scope env variable

Co-authored-by: Michael Weichert <mweichert.com>
Co-authored-by: Daniele Lisi <22307776+danielelisi@users.noreply.github.com>
Co-authored-by: Simon Boissonneault-Robert <simrob7000@gmail.com>
Co-authored-by: Jev Björsell <jev@ecadlabs.com>
  • Loading branch information
4 people authored Jan 27, 2022
1 parent d58e845 commit 75a019a
Showing 1 changed file with 69 additions and 77 deletions.
146 changes: 69 additions & 77 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,42 @@ on:
tags:
- v*

env:
SCOPE: "@ecadlabs"
NPM_REGISTRY: 'https://registry.npmjs.org/'
GH_REGISTRY: 'https://npm.pkg.github.com/'
release:
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref != 'refs/heads/main' || github.run_number }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

env:
SCOPE: '@ecadlabs'
NPM_REGISTRY: 'https://registry.npmjs.org/'
GH_REGISTRY: 'https://npm.pkg.github.com/'

jobs:
build-and-test:

build-binaries:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ${{ matrix.os }}
if: github.event_name != 'release'
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-latest
os_short: ubuntu
deno_target: "x86_64-unknown-linux-gnu"
taqueria_bin: "taqueria"
taqueria_bin: "taq"
- os: windows-latest
os_short: windows
deno_target: "x86_64-pc-windows-msvc"
taqueria_bin: "taqueria.exe"
taqueria_bin: "taq.exe"
- os: macOS-latest
os_short: macos
deno_target: "x86_64-apple-darwin"
taqueria_bin: "taqueria"
taqueria_bin: "taq"

outputs:
public-url-ubuntu: ${{ steps.public-url.outputs.ubuntu }}
Expand All @@ -64,9 +69,9 @@ jobs:
id: build-bin
shell: bash
run: |
deno compile --output taqueria --target $DENO_TARGET --allow-run --allow-write --allow-read --allow-env index.ts
deno compile --output taq --target $DENO_TARGET --allow-run --allow-write --allow-read --allow-env index.ts
[[ $(./"${{ matrix.taqueria_bin }}" init -p ./test_project) == "Project taq'ified!" ]]
mv "${{ matrix.taqueria_bin }}" "taqueria.${{ matrix.deno_target }}"
mv "${{ matrix.taqueria_bin }}" "taq.${{ matrix.deno_target }}"
- name: Authenticate with GCP
id: gcp-auth
Expand All @@ -79,22 +84,19 @@ jobs:
id: upload-file
uses: 'google-github-actions/upload-cloud-storage@v0'
with:
path: "taqueria.${{ matrix.deno_target }}"
path: "taq.${{ matrix.deno_target }}"
destination: "taqueria-artifacts/${{ github.ref }}/${{ github.sha }}"

- name: Set public url
id: public-url
run: |
echo "::set-output name=${{ matrix.os_short }}::https://storage.googleapis.com/taqueria-artifacts/${{ steps.upload-file.outputs.uploaded }}"
publish-npm-packages:
needs: build-and-test
build-and-publish-npm-packages:
runs-on: ubuntu-latest

permissions:
packages: write
contents: read

strategy:
matrix:
include:
Expand All @@ -104,83 +106,60 @@ jobs:
- dir: taqueria-plugin-taquito
# - dir: taqueria-plugin-teztnets
- dir: taqueria-sdk

defaults:
run:
working-directory: ${{ matrix.dir }}

env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_PAT }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
registry-url: ${{ env.GH_REGISTRY }}
scope: ${{ env.SCOPE }}

- name: Update package.json to specify scope for ECAD
run: |
export scope="${{ env.SCOPE }}/"
export name="$(jq -r .name package.json | awk '{split($0,a,"/"); print a[2]}')"
contents=$(jq '.name |= env.scope + env.name' package.json) && \
echo ${contents} > package.json
registry-url: ${{ env.NPM_REGISTRY }}
scope: "${{ env.SCOPE }}"

- name: Check tag suffix
id: check-tag-suffix
if: startsWith(github.ref, 'refs/tags/v') && (contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-test'))
run: |
echo "::set-output name=npm-tag::next"
- name: Install any dependencies
run: npm install
run: npm ci

- name: Build package
run: npm run build

- name: Get current local package version
id: get-local-package-version
run: echo "::set-output name=version::$(jq .version package.json)"

- name: Get current npm registry version
id: get-npm-package-version
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish for PR
if: ${{ github.event_name == 'pull_request' }}
run: |
npm --no-git-tag-version version "0.0.0-pr-${{ github.event.number }}-${GITHUB_SHA::8}"
npm publish --tag "pr-${{ github.event.number }}" --access public
- name: Publish for prerelease
if: ${{ github.event_name == 'release' && github.event.action == 'published' && steps.check-tag-suffix.outputs.npm-tag == 'next'}}
run: |
echo "$(jq -r .name package.json)"
echo "::set-output name=version::$(npm show $(jq -r .name package.json) --json | jq .version)"
npm --no-git-tag-version version "${GITHUB_REF/refs\/tags\/v}"
npm publish --tag 'next' --access public
- name: Publish if new version of package
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: steps.get-npm-package-version.outputs.version < steps.get-local-package-version.outputs.version
run: npm publish
- name: Publish for official release
if: ${{ github.event_name == 'release' && github.event.action == 'published' && steps.check-tag-suffix.outputs.npm-tag != 'next'}}
run: |
npm --no-git-tag-version version "${GITHUB_REF/refs\/tags\/v}"
npm publish --tag 'latest' --access public
pr-comment:
runs-on: ubuntu-latest
needs:
- build-and-test
- publish-npm-packages
- build-binaries
- build-and-publish-npm-packages
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v2

- name: create binary comment
- name: create pr comment
uses: actions/github-script@v5
id: pr-comment
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let body = `
| Artifacts |
| --------- |
| [Linux](${{ needs.build-and-test.outputs.public-url-ubuntu }}) |
| [Windows](${{ needs.build-and-test.outputs.public-url-windows }}) |
| [MacOS](${{ needs.build-and-test.outputs.public-url-macos }}) |
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
- name: create npm comment
uses: actions/github-script@v5
id: npm-comment
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand All @@ -203,13 +182,23 @@ jobs:
const taquito = readInfo("./taqueria-plugin-taquito/package.json")
const sdk = readInfo("./taqueria-sdk/package.json")
const git_short_sha = "${{ github.sha }}".substring(1, 8)
const git_tag = "${{ github.ref }}".split('tags/')[1];
let body = `
| Git Commit | Artifacts |
| ---------- | --------- |
| ${git_short_sha} | [Linux](${{ needs.build-binaries.outputs.public-url-ubuntu }}) <br /> [MacOS](${{ needs.build-binaries.outputs.public-url-macos }}) <br /> [Windows](${{ needs.build-binaries.outputs.public-url-windows }}) |
| npm package installation instructions |
| --------- |
| npm install ${{ env.SCOPE }}/${ligo.name}@${ligo.version} --registry=${{ env.GH_REGISTRY }}|
| npm install ${{ env.SCOPE }}/${smartpy.name}@${smartpy.version} --registry=${{ env.GH_REGISTRY }}|
| npm install ${{ env.SCOPE }}/${taquito.name}@${taquito.version} --registry=${{ env.GH_REGISTRY }}|
| npm install ${{ env.SCOPE }}/${sdk.name}@${sdk.version} --registry=${{ env.GH_REGISTRY }}|
| ------------------------------------- |
| npm install ${{ env.SCOPE }}/${ligo.name}@${ligo.version}-${{ github.event.number }}-${git_short_sha}|
| npm install ${{ env.SCOPE }}/${smartpy.name}@${smartpy.version}-${{ github.event.number }}-${git_short_sha}|
| npm install ${{ env.SCOPE }}/${taquito.name}@${taquito.version}-${{ github.event.number }}-${git_short_sha}|
| npm install ${{ env.SCOPE }}/${sdk.name}@${sdk.version}-${{ github.event.number }}-${git_short_sha}|
`;
github.rest.issues.createComment({
Expand All @@ -222,21 +211,24 @@ jobs:
name: Release
runs-on: ubuntu-latest
needs:
- build-and-test
- build-binaries
- build-and-publish-npm-packages
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v2

- name: Download binaries
id: download-binaries
run: |
mkdir release && cd release
wget ${{ needs.build-and-test.outputs.public-url-ubuntu }} -O taqueria.${GITHUB_REF/refs\/tags\//}-linux
wget ${{ needs.build-and-test.outputs.public-url-windows }} -O taqueria.${GITHUB_REF/refs\/tags\//}-windows.exe
wget ${{ needs.build-and-test.outputs.public-url-macos }} -O taqueria.${GITHUB_REF/refs\/tags\//}-macos
wget ${{ needs.build-binaries.outputs.public-url-ubuntu }} -O taq.${GITHUB_REF/refs\/tags\//}-linux
wget ${{ needs.build-binaries.outputs.public-url-windows }} -O taq.${GITHUB_REF/refs\/tags\//}-windows.exe
wget ${{ needs.build-binaries.outputs.public-url-macos }} -O taq.${GITHUB_REF/refs\/tags\//}-macos
- name: Release
id: release
uses: softprops/action-gh-release@v1
with:
files: |
./release/*
draft: true
draft: true

0 comments on commit 75a019a

Please sign in to comment.