Switch to manual releases & automatic changelog (#9)

This commit is contained in:
folex 2021-07-30 17:53:16 +03:00 committed by GitHub
parent 49f3b39e4a
commit a12ebdf755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 37 deletions

View File

@ -0,0 +1,6 @@
{
"template": "## Changes since ${{FROM_TAG}}\n\n${{CHANGELOG}}\n\n${{UNCATEGORIZED}}",
"pr_template": "- #${{NUMBER}} ${{TITLE}}",
"empty_template": "## No changes since ${{FROM_TAG}}",
"sort": "DESC"
}

View File

@ -2,8 +2,8 @@ name: "publish-release"
on: on:
push: push:
branches: tags:
- "main" - "v*"
jobs: jobs:
npm-publish: npm-publish:
@ -17,6 +17,9 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Set RELEASE_VERSION
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- uses: actions/cache@v2 - uses: actions/cache@v2
with: with:
path: ~/.npm path: ~/.npm
@ -35,54 +38,39 @@ jobs:
- name: Check compilation - name: Check compilation
run: aqua-cli -i . -o /tmp run: aqua-cli -i . -o /tmp
### 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 ### Publish to NPM registry
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: "14" node-version: "14"
registry-url: "https://registry.npmjs.org" registry-url: "https://registry.npmjs.org"
- run: npm publish --access public - name: Publish to NPM
run: |
npm --no-git-tag-version version ${{ env.RELEASE_VERSION }}
npm publish --access public
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN2 }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN2 }}
### Create a release ### Create a release
- name: Create Release - name: Build Changelog
id: create_release id: github_release
uses: actions/create-release@v1 uses: mikepenz/release-changelog-builder-action@v1
with:
configuration: ".github/workflows/changelog_config.json"
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
uses: softprops/action-gh-release@v1
with: with:
tag_name: ${{ env.FINAL_VERSION }} name: aqua-lib ${{ env.RELEASE_VERSION }}
release_name: Aqua lib ${{ env.FINAL_VERSION }} tag_name: ${{ env.RELEASE_VERSION }}
body: | body: |
[${{ env.FINAL_VERSION }} @ NPM registry](https://www.npmjs.com/package/${{ env.PKG_NAME }}/v/${{ env.FINAL_VERSION }}) ${{steps.github_release.outputs.changelog}}
## NPM package
[${{ env.RELEASE_VERSION }} @ NPM registry](https://www.npmjs.com/package/${{ env.PKG_NAME }}/v/${{ env.FINAL_VERSION }})
draft: false draft: false
prerelease: false prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

17
.github/workflows/tag.yml vendored Normal file
View File

@ -0,0 +1,17 @@
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 }}