Skip to content

Commit

Permalink
feat: initial commit (#1)
Browse files Browse the repository at this point in the history
* feat: init from template

* feat: initial commit
  • Loading branch information
ovsds authored Aug 1, 2024
1 parent 611bb08 commit e931a74
Show file tree
Hide file tree
Showing 33 changed files with 39,422 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 120
trim_trailing_whitespace = true

[*.sh]
indent_size = 4
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist/
lib/
node_modules/

commitlint.config.js
vitest.config.ts
18 changes: 18 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"plugins": ["@typescript-eslint"],
"extends": ["@gravity-ui/eslint-config", "@gravity-ui/eslint-config/import-order"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig_eslint.json",
"createDefaultProgram": true
},
"rules": {
"no-constant-condition": "off"
},
"env": {
"node": true,
"es6": true
}
}
16 changes: 16 additions & 0 deletions .github/actions/setup_environment/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Setup Environment"
description: "Setting environment for the project"

inputs:
task-version:
description: "Task version"
required: true
default: "3.33.1"

runs:
using: "composite"
steps:
- name: Install Task
uses: arduino/setup-task@v1
with:
version: ${{ inputs.task-version }}
46 changes: 46 additions & 0 deletions .github/workflows/check-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Check PR

on:
pull_request:
types:
- opened
- reopened
- synchronize

jobs:
check-pr:
runs-on: ubuntu-20.04

permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup_environment

- name: Install Dependencies
run: |
task init
- name: Lint PR
run: |
task lint
- name: Test PR
run: |
task test
- name: Package PR
run: |
task package
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
31 changes: 31 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: E2E

on:
pull_request:
types:
- opened
- reopened
- synchronize

jobs:
e2e-default:
runs-on: ubuntu-20.04

permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Test Run
id: test-run
uses: ./
with:
release_version_regexp: 'test-v?(?<major>[0-9]+)\.(?<minor>[0-9]+)\.(?<patch>[0-9]+).*$'

- name: Assert placeholder
uses: nick-fields/assert-action@v2
with:
actual: ${{ steps.test-run.outputs.version }}
expected: "v1.3.0"
18 changes: 18 additions & 0 deletions .github/workflows/push-version-tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Push version tags

on:
release:
types: [published]

jobs:
push-version-tags:
runs-on: ubuntu-20.04

permissions:
contents: write

steps:
- name: Push Version Tags
uses: ovsds/push-version-tags-action@v1
with:
version: ${{ github.event.release.tag_name }}
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# OS
.DS_Store

# IDE
.idea/
.vscode/

# Dependencies
node_modules/

# Build files
lib/**/*
5 changes: 5 additions & 0 deletions .husky/.huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh

# This loads nvm.sh and sets the correct PATH before running hook
export NVM_DIR="${HOME}/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
6 changes: 6 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fund=false
audit=false
save-exact=true
unsafe-perm=true
engine-strict=true
update-notifier=false
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.15.1
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
lib/
node_modules/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Dmitry Ovsiannikov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
# get-next-release-version-action
# Get Next Release Version Action

[![CI](https://github.com/ovsds/get-next-release-version-action/workflows/Check%20PR/badge.svg)](https://github.com/ovsds/get-next-release-version-action/actions?query=workflow%3A%22%22Check+PR%22%22)
[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-Get%20Next%20Release%20Version-blue.svg)](https://github.com/marketplace/actions/get-next-release-version)

Get Next Release Version Action

## Usage

### Example

```yaml
placeholder # TODO: Add example
```

### Action Inputs

| Name | Description | Default |
| --------------------------------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- |
| `version_shift` | Version shift, used to calculate next version `[major, minor, patch]`. | `minor` |
| `version_template` | Version template to use for version parsing, must contain named groups '<major>', '<minor>', '<patch>' | `v$<major>.$<minor>.$<patch>` |
| `version_override` | Version override, if used then will be output directly. | |
| `release_version_regexp` | Version regexp to use for version parsing, must contain named groups 'major', 'minor', 'patch'. | `v?(?<major>[0-9]+)\.(?<minor>[0-9]+)\.(?<patch>[0-9]+).*$` |
| `release_filter_target_commitish` | Target commitish filter for latest release. | |
| `release_filter_prerelease` | Prerelease filter for latest release. | |
| `github_owner` | GitHub owner. | `${{ github.repository_owner }}` |
| `github_repo` | GitHub repository. | `${{ github.event.repository.name }}` |
| `github_token` | GitHub token. | `${{ github.token }}` |

### Action Outputs

| Name | Description |
| --------- | --------------------- |
| `version` | Next release version. |

## Development

### Global dependencies

- nvm
- node

### Taskfile commands

For all commands see [Taskfile](Taskfile.yaml) or `task --list-all`.

## License

[MIT](LICENSE)
88 changes: 88 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
version: 3

silent: true

vars:
NENV: "node_modules"

tasks:
_prettier:
internal: true
cmds:
- "{{.NENV}}/.bin/prettier {{.COMMAND}}"

_with_nvm:
internal: true
cmds:
- "source ${HOME}/.nvm/nvm.sh && nvm use && {{.COMMAND}}"

init:
desc: Initialize project environment
cmds:
- echo 'Installing node version...'
- source ${HOME}/.nvm/nvm.sh && nvm install

- echo 'Installing node dependencies...'
- task: _with_nvm
vars: { COMMAND: "npm install" }

- echo 'Installing husky pre-commit...'
- task: _with_nvm
vars: { COMMAND: "npm run prepare" }

lint:
desc: Lint project
cmds:
- task: _with_nvm
vars: { COMMAND: "npm run lint:check" }

lint-fix:
desc: Lint fix project
cmds:
- task: _with_nvm
vars: { COMMAND: "npm run lint:fix" }

test:
desc: Test project
cmds:
- task: _with_nvm
vars: { COMMAND: "npm run test" }

package:
desc: Pack project
cmds:
- task: _with_nvm
vars: { COMMAND: "npm run package" }

clean:
desc: Clean project environment
cmds:
- echo 'Cleaning node dependencies...'
- rm -rf {{.NENV}}

dependencies-update:
desc: Update dependencies
cmds:
- echo 'Updating node dependencies...'
- task: _with_nvm
vars: { COMMAND: "npm update" }
- task: _with_nvm
vars: { COMMAND: "npm outdated" }
- task: _with_nvm
vars: { COMMAND: "npm audit" }

update-from-template:
desc: Update project from template
cmds:
- echo 'Updating project from template...'
- cookiecutter
--no-input
--overwrite-if-exists
--output-dir ../
{{.TEMPLATE_PATH}}
project_name="Get Next Release Version Action"
marketplace_name="Get Next Release Version"
action_type="node20"
node_version="v20.15.1"
vars:
TEMPLATE_PATH: '{{.TEMPLATE_PATH | default "https://github.com/ovsds/template-repository-github-action"}}'
40 changes: 40 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "Get Next Release Version"
description: "Get Next Release Version Action"

inputs:
version_shift:
description: "Version shift, used to calculate next version [major, minor, patch]"
default: "minor"
version_template:
description: "Version template to use for version parsing, must contain named groups '{major}', '{minor}', '{patch}'"
default: "v{major}.{minor}.{patch}"
version_override:
description: "Version override, if used then will be output directly"
release_version_regexp:
description: "Version regexp to use for version parsing, must contain named groups 'major', 'minor', 'patch'"
default: '^v?(?<major>[0-9]+)\.(?<minor>[0-9]+)\.(?<patch>[0-9]+).*$'
release_filter_target_commitish:
description: "Target commitish filter for latest release"
release_filter_prerelease:
description: "Prerelease filter for latest release"
github_owner:
description: "Owner of the repository"
default: ${{ github.repository_owner }}
github_repo:
description: "Repository name"
default: ${{ github.event.repository.name }}
github_token:
description: "GitHub token"
default: ${{ github.token }}

outputs:
version:
description: "Next release version"

runs:
using: node20
main: dist/index.js

branding:
icon: "tag"
color: "gray-dark"
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = { extends: ["@commitlint/config-conventional"] };
Loading

0 comments on commit e931a74

Please sign in to comment.