From e17fb666a54a992501a03ced4775c28125e3d7a1 Mon Sep 17 00:00:00 2001 From: Send_Nukez Date: Tue, 26 Oct 2021 22:35:08 +0200 Subject: [PATCH] Add input validation to release action --- .github/workflows/release.yaml | 12 +++++++++--- webpack.config.js | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 39f14d7..db0b97d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: version: - description: 'Version of Release' + description: 'Version of Release (format: X.X.X)' required: true jobs: @@ -12,6 +12,10 @@ jobs: runs-on: ubuntu-latest steps: + - name: Verify Input + run: | + [[ "${{ github.event.inputs.version }}" =~ ^[0-9]\.[0-9]\.[0-9]$ ]] && echo "Matches" && exit 0 || echo "Use versions like '1.2.3'" && exit 1 + - name: Checkout uses: actions/checkout@v2 with: @@ -38,11 +42,13 @@ jobs: uses: montudor/action-zip@v1 - name: Zip Files - run: zip -r DribbblishDynamic_${{ github.event.inputs.version }}.zip * + run: zip -r DribbblishDynamic_v${{ github.event.inputs.version }}.zip * working-directory: dist - name: Release uses: softprops/action-gh-release@v1 with: + name: v${{ github.event.inputs.version }} tag_name: ${{ github.event.inputs.version }} - files: dist/DribbblishDynamic_${{ github.event.inputs.version }}.zip \ No newline at end of file + files: dist/DribbblishDynamic_v${{ github.event.inputs.version }}.zip + fail_on_unmatched_files : true \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 91f57e9..0c630d2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -43,7 +43,7 @@ module.exports = { cleanAfterEveryBuildPatterns: ["*.LICENSE.txt"] }), new webpack.DefinePlugin({ - "process.env.DRIBBBLISH_VERSION": JSON.stringify((process.env.DRIBBBLISH_VERSION || "vDev").substring(1)) // Substring because the script expects the version to be `X.X.X` and not `vX.X.X` + "process.env.DRIBBBLISH_VERSION": JSON.stringify(process.env.DRIBBBLISH_VERSION || "Dev") }), new CopyPlugin({ patterns: [{ from: "src/assets", to: "assets" }, { from: "src/color.ini" }]