mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-05 02:10:18 +00:00
Update CI workflow to tag-based one (#66)
This commit is contained in:
parent
32e1ea4e04
commit
33d7406c55
5
.github/workflows/changelog_config.json
vendored
Normal file
5
.github/workflows/changelog_config.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"template": "${{CHANGELOG}}\n\n${{UNCATEGORIZED}}",
|
||||
"pr_template": "- #${{NUMBER}} ${{TITLE}}",
|
||||
"empty_template": "- no changes"
|
||||
}
|
54
.github/workflows/publish_branch.yml
vendored
54
.github/workflows/publish_branch.yml
vendored
@ -14,60 +14,15 @@ jobs:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
### Extract branch name
|
||||
- name: Extract branch name
|
||||
if: github.event_name != 'pull_request'
|
||||
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
|
||||
id: extract_branch
|
||||
|
||||
- name: Extract branch name
|
||||
if: github.event_name == 'pull_request'
|
||||
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
### Calculate FINAL_VERSION
|
||||
- name: Install jq
|
||||
run: sudo apt-get update && sudo apt-get --yes --force-yes install jq
|
||||
|
||||
- name: Get version from npm and increment
|
||||
run: |
|
||||
# install semver and add it to PATH
|
||||
yarn global add semver
|
||||
PATH="$(yarn global bin):$PATH"
|
||||
|
||||
# sanitize branch name so it can be used as a semver suffix (replace [^0-9a-zA-Z-] with hyphen)
|
||||
SANITIZED_BRANCH="$(echo -n "${{ env.BRANCH_NAME }}" | tr -C '[:alnum:]-' -)"
|
||||
# get package name from package.json
|
||||
PKG_NAME="$(cat package.json | jq -r .name)"
|
||||
|
||||
# take all versions from npm and replace single quotes with double quotes
|
||||
NPM_VERSIONS=$(yarn info --silent "$PKG_NAME" versions 2>/dev/null | tr \' \")
|
||||
# take only versions that contain branch name
|
||||
NPM_VERSIONS_FILTERED=$(echo $NPM_VERSIONS | jq -r ".[] | select(contains(\"$SANITIZED_BRANCH\"))")
|
||||
# flatten into a single line
|
||||
NPM_VERSIONS_FLATTENED=$(echo $NPM_VERSIONS_FILTERED | awk '{print}' ORS=' ')
|
||||
# sort versions according to semver, take highest (last)
|
||||
LAST_NPM_VERSION="$(semver -p $(echo $NPM_VERSIONS_FLATTENED) | tail -n1 || true)"
|
||||
# increment prerelease part of the version
|
||||
PRERELEASE_NPM_VERSION="$(semver --increment prerelease --preid "$SANITIZED_BRANCH" "${LAST_NPM_VERSION}" || true)"
|
||||
|
||||
# take local version
|
||||
LOCAL_VERSION="$(cat package.json | jq -r .version)"
|
||||
# set prerelease part on local version
|
||||
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.
|
||||
|
||||
# take the highest version
|
||||
MAX_VERSION="$(semver "$LOCAL_PRERELEASE_VERSION" "$PRERELEASE_NPM_VERSION" | tail -n1)"
|
||||
|
||||
# save info to env
|
||||
echo "FINAL_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
|
||||
echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV
|
||||
- name: Extract branch name
|
||||
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
|
||||
|
||||
### Set version
|
||||
- name: Set version to ${{ env.FINAL_VERSION }}
|
||||
run: yarn version --new-version ${{ env.FINAL_VERSION }} --no-git-tag-version
|
||||
- name: Set version
|
||||
run: npm version prerelease --no-git-tag-version --preid ${{ env.BRANCH_NAME }}-${{ github.run_number }}
|
||||
|
||||
### Publish to NPM registry
|
||||
- uses: actions/setup-node@v1
|
||||
@ -83,3 +38,4 @@ jobs:
|
||||
- run: npm publish --access public --tag=beta
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
|
73
.github/workflows/publish_release.yml
vendored
73
.github/workflows/publish_release.yml
vendored
@ -1,73 +0,0 @@
|
||||
name: "publish-release"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
|
||||
jobs:
|
||||
npm-publish:
|
||||
name: "Publish"
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
### Calculate FINAL_VERSION
|
||||
- name: Install jq
|
||||
run: sudo apt-get update && sudo apt-get --yes --force-yes install jq
|
||||
|
||||
- name: Get version from npm and increment
|
||||
run: |
|
||||
yarn global add semver
|
||||
PATH="$(yarn global bin):$PATH"
|
||||
|
||||
# take npm version and increment it
|
||||
PKG_NAME="$(cat package.json | jq -r .name)"
|
||||
NPM_VERSION="$(yarn info --silent "$PKG_NAME" version || true)"
|
||||
NEXT_NPM_VERSION="$(semver --increment patch "$NPM_VERSION")"
|
||||
|
||||
# take local version
|
||||
LOCAL_VERSION="$(cat package.json | jq -r .version)"
|
||||
|
||||
# take maximum of the local and NEXT_NPM versions
|
||||
MAX_VERSION="$(semver "$LOCAL_VERSION" "$NEXT_NPM_VERSION" "0.0.0" | tail -n1)"
|
||||
|
||||
# save info to env
|
||||
echo "FINAL_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
|
||||
echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV
|
||||
|
||||
### Set version
|
||||
- name: Set version to ${{ env.FINAL_VERSION }}
|
||||
run: yarn version --new-version ${{ env.FINAL_VERSION }} --no-git-tag-version
|
||||
|
||||
### Publish to NPM registry
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '14'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- run: npm i
|
||||
- run: npm run build
|
||||
|
||||
- run: npm publish --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
### Create a release
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ env.FINAL_VERSION }}
|
||||
release_name: Fluence Network ${{ env.FINAL_VERSION }}
|
||||
body: |
|
||||
[${{ env.FINAL_VERSION }} @ NPM registry](https://www.npmjs.com/package/${{ env.PKG_NAME }}/v/${{ env.FINAL_VERSION }})
|
||||
draft: false
|
||||
prerelease: false
|
61
.github/workflows/release.yml
vendored
Normal file
61
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
name: "release"
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
npm-publish:
|
||||
name: "Publish"
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set env
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
|
||||
### Set version
|
||||
- name: Set version to ${{ env.RELEASE_VERSION }}
|
||||
run: npm version --new-version ${{ env.RELEASE_VERSION }} --no-git-tag-version
|
||||
|
||||
### Publish to NPM registry
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '14'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- run: npm i
|
||||
- run: npm run build
|
||||
|
||||
- run: npm publish --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
### Create a release
|
||||
- name: Build Changelog
|
||||
id: changelog
|
||||
uses: mikepenz/release-changelog-builder-action@v1
|
||||
with:
|
||||
configuration: ".github/workflows/changelog_config.json"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Release
|
||||
id: release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
name: aqua-dht ${{ env.RELEASE_VERSION }}
|
||||
tag_name: ${{ env.RELEASE_VERSION }}
|
||||
files: |
|
||||
aqua-dht.tar.gz
|
||||
body: ${{steps.changelog.outputs.changelog}}
|
||||
draft: false
|
||||
prerelease: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
18
.github/workflows/tag.yml
vendored
Normal file
18
.github/workflows/tag.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
name: "tag"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
tag:
|
||||
name: "Tag"
|
||||
runs-on: "ubuntu-latest"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Bump version and push tag
|
||||
id: tag_version
|
||||
uses: mathieudutour/github-tag-action@v5.5
|
||||
with:
|
||||
github_token: ${{ secrets.PERSONAL_TOKEN }}
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@fluencelabs/fluence",
|
||||
"version": "0.10.1",
|
||||
"version": "0.10.2-0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@fluencelabs/fluence",
|
||||
"version": "0.10.1",
|
||||
"version": "0.10.2-0",
|
||||
"description": "JS SDK for the Fluence network",
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
|
Loading…
Reference in New Issue
Block a user