From feacde371b16eca39253e43e57c299fce2d16a11 Mon Sep 17 00:00:00 2001 From: Mikhail Karasikov Date: Sun, 6 Feb 2022 19:11:33 +0100 Subject: [PATCH] check version consistency when adding a version tag --- .github/workflows/auto_release_tag.yml | 22 ---------------------- .github/workflows/main.yml | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 22 deletions(-) delete mode 100644 .github/workflows/auto_release_tag.yml diff --git a/.github/workflows/auto_release_tag.yml b/.github/workflows/auto_release_tag.yml deleted file mode 100644 index e175550ffa..0000000000 --- a/.github/workflows/auto_release_tag.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Version AutoTag - -on: - push: - paths: - - package.json - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: Jaliborc/action-general-autotag@1.0.1 - with: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - source_file: "package.json" - extraction_regex: "\\s*\"version\"s*:\\s*\"([\\d\\.]+)\"" - tag_format: "v{version}" - tag_message: "New version" - diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 41ae6f936f..20f7d08e75 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -287,8 +287,23 @@ jobs: run: | echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} + # from https://stackoverflow.com/a/61919791/6869319 + - name: read current version + id: read_version + run: | + content=`cat package.json` + # the following lines are only required for multi line json + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + # end of optional handling for multi line json + echo "::set-output name=packageJson::$content" + - name: build source archive including submodules run: | + [[ v${{fromJson(steps.read_version.outputs.packageJson).version}} == ${{ steps.tag_name.outputs.TAG }} ]] \ + || (echo "::error file=package.json::Version in package.json (v${{fromJson(steps.read_version.outputs.packageJson).version}}) does not match tag ${{ steps.tag_name.outputs.TAG }}. Update package.json and set the tag again."; \ + exit 1) mkdir -p artifacts/sources tag=${{ steps.tag_name.outputs.TAG }} bash .github/workflows/git-archive-all.sh --format tar.gz artifacts/sources/${tag}-sources-with-submodules.tar.gz