Skip to content

Commit

Permalink
Merge pull request #70 from GregoryGost/develop
Browse files Browse the repository at this point in the history
v1.0.4
  • Loading branch information
GregoryGost authored Sep 29, 2024
2 parents 05ab36a + a3d001e commit e428d98
Show file tree
Hide file tree
Showing 29 changed files with 4,899 additions and 4,683 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ updates:
directory: /
schedule:
interval: weekly
day: sunday
time: '09:00'
timezone: 'Europe/Moscow'
labels:
- actions
reviewers:
- GregoryGost
groups:
actions-minor:
update-types:
Expand All @@ -14,6 +21,14 @@ updates:
directory: /
schedule:
interval: weekly
day: sunday
time: '09:00'
timezone: 'Europe/Moscow'
labels:
- pnpm
- dependencies
reviewers:
- GregoryGost
groups:
development:
dependency-type: development
Expand Down
16 changes: 16 additions & 0 deletions .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,19 @@ MD004:
# Ordered list item prefix
MD029:
style: one

# Spaces after list markers
MD030:
ul_single: 1
ol_single: 1
ul_multi: 1
ol_multi: 1

# Code block style
MD046:
style: fenced

# Line length
MD013:
tables: false
line_length: 120
2 changes: 1 addition & 1 deletion .github/linters/.yaml-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ rules:
present: false
line-length:
level: warning
max: 80
max: 120
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
17 changes: 12 additions & 5 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ name: Check Transpiled JavaScript
on:
push:
branches:
- main
- develop
pull_request:
branches:
- develop

permissions:
contents: read
Expand All @@ -31,7 +32,7 @@ jobs:

- name: Install pnpm
id: setup-pnpm
uses: pnpm/action-setup@v3
uses: pnpm/action-setup@v4
with:
version: ^9

Expand All @@ -50,18 +51,24 @@ jobs:
id: build
run: pnpm run bundle

# This will fail the workflow if the PR wasn't created by Dependabot.
# This will fail the workflow if the `dist/` directory is different than
# expected.
- name: Compare Directories
id: diff
run: |
if [ ! -d dist/ ]; then
echo "Expected dist/ directory does not exist. See status below:"
ls -la ./
exit 1
fi
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi
# If `dist/` was different than expected, and this was not a Dependabot
# PR, upload the expected version as a workflow artifact.
# If `dist/` was different than expected, upload the expected version as a
# workflow artifact.
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
name: Upload Artifact
id: upload
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Continuous Integration

on:
pull_request:
push:
branches:
- main
- develop
pull_request:
branches:
- develop

permissions:
Expand All @@ -22,7 +23,7 @@ jobs:

- name: Install pnpm
id: setup-pnpm
uses: pnpm/action-setup@v3
uses: pnpm/action-setup@v4
with:
version: ^9

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ name: CodeQL
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
schedule:
- cron: '31 7 * * 3'

permissions: read-all

jobs:
analyze:
name: Analyze
Expand All @@ -36,15 +36,15 @@ jobs:

- name: Initialize CodeQL
id: initialize
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
source-root: src

- name: Autobuild
id: autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
id: analyze
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
5 changes: 4 additions & 1 deletion .github/workflows/develop-self-versioning.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
name: Develop Self Versioning

on:
push:
pull_request:
branches:
- develop
types:
- closed

permissions:
contents: write

jobs:
develop-version:
if: github.event.pull_request.merged == true
name: Develop Self Versioning job
runs-on: ubuntu-latest

Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Lint Codebase

on:
push:
branches:
- develop
pull_request:
branches:
- develop

permissions:
contents: read
packages: read
statuses: write

jobs:
lint:
name: Lint Codebase
runs-on: ubuntu-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install pnpm
id: setup-pnpm
uses: pnpm/action-setup@v4
with:
version: ^9

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm

- name: Install Dependencies
id: pnpm-install
run: pnpm i --frozen-lockfile

- name: Lint Codebase
id: super-linter
uses: super-linter/super-linter/slim@v7.1.0
env:
DEFAULT_BRANCH: develop
FILTER_REGEX_EXCLUDE: dist/**/*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPESCRIPT_DEFAULT_STYLE: prettier
VALIDATE_ALL_CODEBASE: true
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_TYPESCRIPT_STANDARD: false
VALIDATE_JSCPD: false
21 changes: 21 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"MD004": {
"style": "dash"
},
"MD029": {
"style": "one"
},
"MD030": {
"ul_single": 1,
"ol_single": 1,
"ol_multi": 1,
"ul_multi": 1
},
"MD046": {
"style": "fenced"
},
"MD013": {
"tables": false,
"line_length": 120
}
}
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.10.0
20.11.0
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist/
node_modules/
coverage/

pnpm-lock.yaml
2 changes: 1 addition & 1 deletion .prettierrc.json → .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "lf"
}
}
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
![CodeSize](https://img.shields.io/github/languages/code-size/GregoryGost/version-tagger)
![IssuesOpen](https://img.shields.io/github/issues-raw/GregoryGost/version-tagger)
![LatestRelease](https://img.shields.io/github/v/release/GregoryGost/version-tagger)
![LatestTag](https://img.shields.io/github/v/tag/GregoryGost/version-tagger?sort=date&logo=substack&logoColor=white)
![CI](https://github.com/GregoryGost/version-tagger/actions/workflows/ci.yml/badge.svg)
[![Check dist/](https://github.com/GregoryGost/version-tagger/actions/workflows/check-dist.yml/badge.svg)](https://github.com/GregoryGost/version-tagger/actions/workflows/check-dist.yml)
[![CodeQL](https://github.com/GregoryGost/version-tagger/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/GregoryGost/version-tagger/actions/workflows/codeql-analysis.yml)
[![Coverage](./badges/coverage.svg)](./badges/coverage.svg)
![Watchers](https://img.shields.io/github/watchers/GregoryGost/version-tagger)
![RepoStars](https://img.shields.io/github/stars/GregoryGost/version-tagger)

GitHub Action to automate tag-based version control. For both production and development.

Expand All @@ -27,28 +30,28 @@ Configure permission:

| name | required | description | default |
| --------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| **token** | `true` | The GitHub Token to use for reference management in the repo | |
| **version** | `false` | Version from previous action output. Pattern semver <https://semver.org>: `x.y.z` | `0.1.0` |
| **token** | `true` | The GitHub Token to use for reference management in the repository | |
| **version** | `false` | Version from previous action output. Pattern SemVer <https://semver.org>: `x.y.z` | `0.1.0` |
| **prefix** | `false` | A prefix that will appear immediately before the tag version. Example: `v` => `v1.0.0` | `''` |
| **postfix** | `false` | Postfix that will appear immediately after the tag version. Example: `beta` => `v1.0.0-beta.0` | `''` |
| **postfixnoup** | `false` | Do not apply version upgrade to postfix. No number will be added to the postfix. Example: `v1.0.0-beta`, `2.5.1-rc` | `false` |
| **metadata** | `false` | Add your own metadata, or use the sliced sha1 version hash.. Example: `build123` or `fyf2c5fr` => `v1.0.0-beta.1+fyf2c5fr` | `''` |
| **releasetype** | `false` | Used in conjunction with a `auto` parameter (but there is an exception `patch`). Release type version. `major`(X.y.z) or `minor`(x.Y.z) or `patch`(x.y.Z). If not specified, then no version will be incremented. All variants: `major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, `prerelease`. More in semver doc: <https://github.com/npm/node-semver/blob/main/README.md> | `''` |
| **releasetype** | `false` | Used in conjunction with a `auto` parameter (but there is an exception `patch`). Release type version. `major`(X.y.z) or `minor`(x.Y.z) or `patch`(x.y.Z). If not specified, then no version will be incremented. All variants: `major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, `prerelease`. More in SemVer doc: <https://github.com/npm/node-semver/blob/main/README.md> | `''` |
| **auto** | `false` | Forced version update. DANGEROUS-1!!! May be incorrect because in some cases duplicates the version upgrade. DANGEROUS-2!!! The version in the file may not match what will be in the tags as a result. If `FALSE`, no automatic promotions will be made. | `false` |
| **dryrun** | `false` | If this value is true, the tag will not be pushed. Use for test this action | `false` |

### Outputs

| name | description |
| ---------- | ------------------------------------------------------------- |
| **newtag** | The GitHub Token to use for reference management in the repo. |
| name | description |
| ---------- | ------------------------------------------------------------------- |
| **newtag** | The GitHub Token to use for reference management in the repository. |

## Usage

Example `.github/workflows/develop.yml` that will execute when a `push` or `pull_request` to the `develop` branch
occurs.

`token: ${{ secrets.GITHUB_TOKEN }}` - is required parameter. Github automatically generates this token. There is no
`token: ${{ secrets.GITHUB_TOKEN }}` - is required parameter. GitHub automatically generates this token. There is no
need to create it separately. Plus it's not safe!

```yml
Expand Down Expand Up @@ -120,7 +123,7 @@ Gets the version `2.0.0` from the previous step workflow
### 3. Example: Repository last tag version (no use package.json)

Gets the versions array `['v3.0.0-rc.12', 'v3.0.0-rc.11', 'v3.0.0-rc.10']` from the tag list in repository
Removes pre-release postfixes when using the release type.
Removes prerelease postfixes when using the release type.

- Result: `v3.0.0` if releasetype: `patch` or `minor` or `major` or etc.
- Next result: `v3.0.1` if releasetype `patch`
Expand Down Expand Up @@ -207,7 +210,7 @@ Gets the version `6.0.0` from the `package.json` file.

Gets the version `7.0.0` from the `package.json` file.

- Result: `v7.0.0` to output step github action
- Result: `v7.0.0` to output step GitHub Action

```yml
- name: Create tag
Expand Down
1 change: 1 addition & 0 deletions __tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Unit tests for src/class/config.ts
*/

import { expect } from '@jest/globals';
import { cwd } from 'node:process';
import { normalize, join } from 'node:path';
import { readFileSync } from 'node:fs';
Expand Down
1 change: 1 addition & 0 deletions __tests__/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Unit tests for src/class/github.ts
*/

import { expect } from '@jest/globals';
import { join } from 'node:path';
import * as core from '@actions/core';
import * as github from '@actions/github';
Expand Down
2 changes: 1 addition & 1 deletion __tests__/github_payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"sender": {
"type": "User"
}
}
}
1 change: 1 addition & 0 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Unit tests for src/index.ts
*/

import { expect } from '@jest/globals';
import { join } from 'node:path';
import * as core from '@actions/core';

Expand Down
3 changes: 2 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Unit tests for src/class/main.ts
*/

import { expect } from '@jest/globals';
import { cwd } from 'node:process';
import { normalize, join } from 'node:path';
import * as core from '@actions/core';
Expand All @@ -26,7 +27,7 @@ process.env.GITHUB_SHA = 'c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c';
process.env.GITHUB_HEAD_REF = 'develop';

// Mock the GitHub Actions core library
let getInputMock: jest.SpyInstance;
let getInputMock: jest.SpyInstance; // TODO: jest.SpiedFunction<typeof core.getInput>
let getBooleanInputMock: jest.SpyInstance;
let setFailedMock: jest.SpyInstance;
let setOutputMock: jest.SpyInstance;
Expand Down
Loading

0 comments on commit e428d98

Please sign in to comment.