diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..0193250 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,42 @@ +name: Create Tag + +on: + workflow_dispatch: + inputs: + version: + description: 'Release tag' + required: true + +jobs: + tag: + name: Create tag + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 0 + - name: 'Get previous tag' + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@v1" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: 'Get possible next tags' + id: semvers + uses: "WyriHaximus/github-action-next-semvers@v1.1" + with: + version: ${{ steps.previoustag.outputs.tag }} + - name: 'Verify input version' + if: github.event.inputs.version != steps.semvers.outputs.v_major && github.event.inputs.version != steps.semvers.outputs.v_minor && github.event.inputs.version != steps.semvers.outputs.v_patch + run: exit 1 + - name: 'Create new tag' + if: success() + uses: actions/github-script@v4.0.2 + with: + github-token: ${{ secrets.TAG_PSAT }} + script: | + github.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: "refs/tags/${{ github.event.inputs.version }}", + sha: context.sha + })