Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit 4642a8b

Browse files
committed
actions: setup workflows
1 parent 6cd7545 commit 4642a8b

7 files changed

Lines changed: 151 additions & 4 deletions

File tree

.github/workflows/build.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags:
8+
- '*'
9+
- '!v*' # Don't run on version tags, instead the release workflow will include this file and call the build step
10+
workflow_call: {}
11+
12+
jobs:
13+
build:
14+
name: Build
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Setup .npmrc
19+
run: cp tools/_.npmrc .npmrc
20+
- name: Cache node_modules/
21+
uses: actions/cache@v4
22+
with:
23+
path: node_modules
24+
key: node_modules
25+
- name: Install node_modules/
26+
uses: docker://node:18.20.8-alpine3.21
27+
with:
28+
args: yarn --silent install --frozen-lockfile
29+
env:
30+
NPM_TOKEN: ${{ secrets.NPM_TOKEN_RO }}
31+
- name: Build the release
32+
uses: docker://node:18.20.8-alpine3.21
33+
with:
34+
entrypoint: tools/build.sh
35+
env:
36+
EMBEDLY_KEY: ${{ secrets.EMBEDLY_KEY }}
37+
- name: Create compilation artifact
38+
run: tar -cf ../dist.tar *
39+
working-directory: dist
40+
- uses: actions/upload-artifact@v4
41+
with:
42+
name: dist.tar
43+
path: dist.tar
44+
retention-days: 1

.github/workflows/release.yaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
uses: ./.github/workflows/build.yaml
11+
secrets: inherit
12+
13+
publish:
14+
name: Publish to npmjs.org
15+
needs: [build]
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Setup .npmrc
20+
run: cp tools/_.npmrc .npmrc
21+
- uses: actions/download-artifact@v4
22+
with:
23+
name: dist.tar
24+
- name: Unpack compilation artifact
25+
run: mkdir dist && tar -xf dist.tar -C dist
26+
- name: Configure the package.json for publishing
27+
run: jq --arg version "${REF#refs\/tags\/v}" 'del(.devDependencies,.scripts,.private) | .version=$version' package.json > dist/package.json
28+
env:
29+
REF: ${{ github.ref }}
30+
- name: Include README.md in the package
31+
run: cp README.md dist/
32+
- name: Publish the package
33+
uses: docker://node:18.20.8-alpine3.21
34+
with:
35+
args: yarn --cwd dist publish --no-git-tag-version
36+
env:
37+
NPM_TOKEN: ${{ secrets.NPM_TOKEN_RW }}
38+
- name: Update compilation artifact
39+
run: tar -cf ../dist.tar *
40+
working-directory: dist
41+
- uses: actions/upload-artifact@v4
42+
with:
43+
name: dist.tar
44+
path: dist.tar
45+
retention-days: 1
46+
47+
create-release:
48+
name: Create GitHub Release
49+
needs: [publish]
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Determine version
53+
id: version
54+
run: printf "tag=%s\n" "${REF#refs\/tags\/}" >> $GITHUB_OUTPUT
55+
env:
56+
REF: ${{ github.ref }}
57+
- name: Checkout code
58+
uses: actions/checkout@v4
59+
with:
60+
ref: ${{ steps.version.outputs.tag }}
61+
- name: Get release notes from tag
62+
id: tag-message
63+
run: |
64+
eof="$(openssl rand -hex 8)"
65+
printf "message<<%s\n%s\n%s\n" "$eof" "$(git tag -l --format='%(contents)' "${REF#refs\/tags\/}")" "$eof" >> $GITHUB_OUTPUT
66+
env:
67+
REF: ${{ github.ref }}
68+
- uses: actions/download-artifact@v4
69+
with:
70+
name: dist.tar
71+
- name: Compress release artifact
72+
run: gzip dist.tar && mv dist.tar.gz ${{ steps.version.outputs.tag }}.tar.gz
73+
- name: Create Release
74+
uses: ncipollo/release-action@v1
75+
with:
76+
name: ${{ steps.version.outputs.tag }}
77+
body: ${{ steps.tag-message.outputs.message }}
78+
draft: false
79+
prerelease: false
80+
artifacts: ${{ steps.version.outputs.tag }}.tar.gz
81+
artifactErrorsFailBuild: true
82+
artifactContentType: application/gzip

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
node_modules
1+
dist/
2+
node_modules/
23
npm-debug.log
File renamed without changes.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
"name": "@secoya/embedly",
33
"version": "3.0.0",
44
"description": "Embedly client library for node",
5-
"homepage": "https://github.com/embedly/embedly-node",
5+
"homepage": "https://github.com/secoya/embedly-node",
66
"keywords": [],
7+
"private": true,
78
"author": "Bob Corsaro <bob@embed.ly> (http://www.google.com/profiles/rcorsaro)",
89
"repository": {
910
"type": "git",
10-
"url": "git://github.com/embedly/embedly-node.git"
11+
"url": "git://github.com/secoya/embedly-node.git"
1112
},
1213
"bugs": {
13-
"url": "http://github.com/embedly/embedly-node/issues/"
14+
"url": "http://github.com/secoya/embedly-node/issues/"
1415
},
1516
"directories": {
1617
"doc": "./docs",

tools/_.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
2+
registry=https://registry.npmjs.org/

tools/build.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env sh
2+
# The github build action uses the official nodejs container does not have bash
3+
# so this script must be POSIX sh compliant
4+
5+
set -e
6+
cd "$(dirname "$0")/.."
7+
PATH=$PWD/node_modules/.bin:$PATH
8+
export LOGFORMAT=cli
9+
10+
main() {
11+
rm -Rf dist/
12+
mkdir -p dist/
13+
mocha
14+
cp -r index.js LICENSE bin/ dist/
15+
}
16+
17+
main "$@"

0 commit comments

Comments
 (0)