Skip to content

Commit 33d7406

Browse files
authored
Update CI workflow to tag-based one (#66)
1 parent 32e1ea4 commit 33d7406

File tree

7 files changed

+91
-124
lines changed

7 files changed

+91
-124
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"template": "${{CHANGELOG}}\n\n${{UNCATEGORIZED}}",
3+
"pr_template": "- #${{NUMBER}} ${{TITLE}}",
4+
"empty_template": "- no changes"
5+
}

.github/workflows/publish_branch.yml

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,15 @@ jobs:
1414
shell: bash
1515

1616
steps:
17-
### Extract branch name
18-
- name: Extract branch name
19-
if: github.event_name != 'pull_request'
20-
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
21-
id: extract_branch
22-
23-
- name: Extract branch name
24-
if: github.event_name == 'pull_request'
25-
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
26-
2717
- name: Checkout repository
2818
uses: actions/checkout@v2
2919

30-
### Calculate FINAL_VERSION
31-
- name: Install jq
32-
run: sudo apt-get update && sudo apt-get --yes --force-yes install jq
33-
34-
- name: Get version from npm and increment
35-
run: |
36-
# install semver and add it to PATH
37-
yarn global add semver
38-
PATH="$(yarn global bin):$PATH"
39-
40-
# sanitize branch name so it can be used as a semver suffix (replace [^0-9a-zA-Z-] with hyphen)
41-
SANITIZED_BRANCH="$(echo -n "${{ env.BRANCH_NAME }}" | tr -C '[:alnum:]-' -)"
42-
# get package name from package.json
43-
PKG_NAME="$(cat package.json | jq -r .name)"
44-
45-
# take all versions from npm and replace single quotes with double quotes
46-
NPM_VERSIONS=$(yarn info --silent "$PKG_NAME" versions 2>/dev/null | tr \' \")
47-
# take only versions that contain branch name
48-
NPM_VERSIONS_FILTERED=$(echo $NPM_VERSIONS | jq -r ".[] | select(contains(\"$SANITIZED_BRANCH\"))")
49-
# flatten into a single line
50-
NPM_VERSIONS_FLATTENED=$(echo $NPM_VERSIONS_FILTERED | awk '{print}' ORS=' ')
51-
# sort versions according to semver, take highest (last)
52-
LAST_NPM_VERSION="$(semver -p $(echo $NPM_VERSIONS_FLATTENED) | tail -n1 || true)"
53-
# increment prerelease part of the version
54-
PRERELEASE_NPM_VERSION="$(semver --increment prerelease --preid "$SANITIZED_BRANCH" "${LAST_NPM_VERSION}" || true)"
55-
56-
# take local version
57-
LOCAL_VERSION="$(cat package.json | jq -r .version)"
58-
# set prerelease part on local version
59-
LOCAL_PRERELEASE_VERSION="$(semver --increment prerelease --preid "$SANITIZED_BRANCH" "${LOCAL_VERSION}-0")" # added '-0' here to avoid semver erroneously increment patch octet. Any suffix works, '-0' is chosen deliberately.
60-
61-
# take the highest version
62-
MAX_VERSION="$(semver "$LOCAL_PRERELEASE_VERSION" "$PRERELEASE_NPM_VERSION" | tail -n1)"
63-
64-
# save info to env
65-
echo "FINAL_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
66-
echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV
20+
- name: Extract branch name
21+
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
6722

6823
### Set version
69-
- name: Set version to ${{ env.FINAL_VERSION }}
70-
run: yarn version --new-version ${{ env.FINAL_VERSION }} --no-git-tag-version
24+
- name: Set version
25+
run: npm version prerelease --no-git-tag-version --preid ${{ env.BRANCH_NAME }}-${{ github.run_number }}
7126

7227
### Publish to NPM registry
7328
- uses: actions/setup-node@v1
@@ -83,3 +38,4 @@ jobs:
8338
- run: npm publish --access public --tag=beta
8439
env:
8540
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
41+

.github/workflows/publish_release.yml

Lines changed: 0 additions & 73 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "release"
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
npm-publish:
10+
name: "Publish"
11+
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v2
19+
20+
- name: Set env
21+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
22+
23+
### Set version
24+
- name: Set version to ${{ env.RELEASE_VERSION }}
25+
run: npm version --new-version ${{ env.RELEASE_VERSION }} --no-git-tag-version
26+
27+
### Publish to NPM registry
28+
- uses: actions/setup-node@v1
29+
with:
30+
node-version: '14'
31+
registry-url: 'https://registry.npmjs.org'
32+
33+
- run: npm i
34+
- run: npm run build
35+
36+
- run: npm publish --access public
37+
env:
38+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39+
40+
### Create a release
41+
- name: Build Changelog
42+
id: changelog
43+
uses: mikepenz/release-changelog-builder-action@v1
44+
with:
45+
configuration: ".github/workflows/changelog_config.json"
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Release
50+
id: release
51+
uses: softprops/action-gh-release@v1
52+
with:
53+
name: aqua-dht ${{ env.RELEASE_VERSION }}
54+
tag_name: ${{ env.RELEASE_VERSION }}
55+
files: |
56+
aqua-dht.tar.gz
57+
body: ${{steps.changelog.outputs.changelog}}
58+
draft: false
59+
prerelease: false
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tag.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
name: "tag"
3+
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
tag:
9+
name: "Tag"
10+
runs-on: "ubuntu-latest"
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Bump version and push tag
15+
id: tag_version
16+
uses: mathieudutour/[email protected]
17+
with:
18+
github_token: ${{ secrets.PERSONAL_TOKEN }}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fluencelabs/fluence",
3-
"version": "0.10.1",
3+
"version": "0.10.2-0",
44
"description": "JS SDK for the Fluence network",
55
"main": "./dist/index.js",
66
"typings": "./dist/index.d.ts",

0 commit comments

Comments
 (0)