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