Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rebuild project with nodejs #165

Merged
merged 25 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4c0bec5
build: allow setting image info with Makefile
TomerFi Feb 3, 2024
979dc13
build: default image builder set to podman
TomerFi Feb 4, 2024
ea2e4fe
build: switched to ISC license
TomerFi Feb 4, 2024
00c75da
refactor: rewrite project with nodejs
TomerFi Feb 4, 2024
bd064ba
test: added unit tests for manual version bumps
TomerFi Feb 4, 2024
c26ce8b
test: added unit tests for automatic bumps
TomerFi Feb 5, 2024
59c3541
build: fix up the Dockerfile and other project-related stuff
TomerFi Feb 5, 2024
5e4d19a
ci: better ci and other project related stuff
TomerFi Feb 5, 2024
9a9e7a8
docs: added code documentation
TomerFi Feb 6, 2024
16afee0
docs: updated contributing documents
TomerFi Feb 6, 2024
92ff1d7
docs: update README
TomerFi Feb 6, 2024
18cf5e0
refactor: change original return key to current
TomerFi Feb 6, 2024
990bd22
fix: fixed support for default values in module entering point
TomerFi Feb 7, 2024
2f0a155
docs: added module usage example in README
TomerFi Feb 7, 2024
92c2cc9
ci: fixed stage workflow
TomerFi Feb 7, 2024
a4e71d7
ci: added metadata to the container image
TomerFi Feb 7, 2024
a96c099
ci: used experimental gha cache type from building images
TomerFi Feb 7, 2024
5b40814
ci: added step for updating docker hub image description
TomerFi Feb 7, 2024
63ab068
chore: droppes shelljs usage from source code (used only in tests)
TomerFi Feb 7, 2024
3d4b69e
chore: removed preset selection and set static conventionalcommits
TomerFi Feb 8, 2024
46849dc
refactored: preset creation is now local
TomerFi Feb 8, 2024
24cfef4
docs: clarified contributing guidelines
TomerFi Feb 8, 2024
4cab8ad
docs: fixed tag close in README
TomerFi Feb 8, 2024
62daf02
docs: clarified README
TomerFi Feb 8, 2024
8feb347
docs: clarify breaking changes v2 to v3
TomerFi Feb 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .dockerignore

This file was deleted.

18 changes: 0 additions & 18 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
# editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true

[**.{yaml,yml}]
indent_style = space
indent_size = 2
max_line_length = 100
trim_trailing_whitespace = true

[**.md]
max_line_length = 120
trim_trailing_whitespace = false

[**.{sh,bash,zsh,csh,ksh,fish}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[Makefile*]
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
14 changes: 14 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
root: true
parserOptions:
ecmaVersion: latest
env:
node: true
commonjs: true
mocha: true
shelljs: true
extends:
- "eslint:recommended"
- "plugin:editorconfig/all"
plugins:
- "editorconfig"
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@ updates:
include: "scope"
assignees:
- "tomerfi"

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
labels:
- "type: dependencies"
commit-message:
prefix: "build"
include: "scope"
assignees:
- "tomerfi"
4 changes: 0 additions & 4 deletions .github/linters/.yaml-lint.yml

This file was deleted.

97 changes: 50 additions & 47 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,66 @@ on:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
pull-requests: read

jobs:
lint:
runs-on: ubuntu-latest
name: Lint project
permissions:
pull-requests: write
code:
strategy:
matrix:
node: ['20', 'latest']
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: "Test project { os: ${{ matrix.os }}, node: ${{ matrix.node }} }"
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
fetch-depth: 0
node-version: ${{ matrix.node }}
cache: npm

- name: Lint sources
uses: docker://ghcr.io/github/super-linter:slim-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
IGNORE_GITIGNORED_FILES: true
IGNORE_GENERATED_FILES: true
VALIDATE_DOCKERFILE: true
VALIDATE_EDITORCONFIG: true
VALIDATE_GITHUB_ACTIONS: true
VALIDATE_MARKDOWN: true
VALIDATE_SHELL_SHFMT: true
VALIDATE_YAML: true
# required for testing
- name: Configure git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"

build:
runs-on: ubuntu-latest
needs: [lint]
name: Build docker image
permissions:
pull-requests: read
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install project modules
run: npm ci

- name: Setup Docker Buildx
uses: docker/[email protected]
- name: Lint source files
run: npm run lint

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile', '.dockerignore') }}
- name: Run unit tests
run: npm test

image:
runs-on: ubuntu-latest
needs: [code]
name: Test container image
env:
TESTING_TAG: tomerfi/version-bumper:testing
steps:
- name: Setup docker buildx
uses: docker/setup-buildx-action@v3

- name: Build docker image (no push)
uses: docker/build-push-action@v5.1.0
- name: Build image
uses: docker/build-push-action@v5
with:
context: .
build-args: |
VCS_REF=${{ github.sha }}
BUILD_DATE=$(date +'%Y-%m-%d')
VERSION=testing
tags: tomerfi/version-bumper:testing
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: ${{ env.TESTING_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
load: true

- name: Delete docker image
run: docker image rm tomerfi/version-bumper:testing
- name: Test image run
run: |
pattern='^version-bumper ([0-9]\.){2}[0-9](.+)?$'
sut=$(docker run --rm ${{ env.TESTING_TAG }} -v)
[[ $sut =~ $pattern ]] || exit 1
123 changes: 72 additions & 51 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,93 +8,114 @@ on:
description: "Release title"
required: false

env:
PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64/v8

jobs:
release:
runs-on: ubuntu-latest
environment: deployment
name: Build, publish, release, and announce
name: Publish and Release
steps:
- name: Source checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Setup QEMU
uses: docker/[email protected]
- name: Install node 20
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm

- name: Setup Docker Buildx
uses: docker/[email protected]
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"

- name: Cache Docker layers
uses: actions/cache@v4
- name: Setup qemu
uses: docker/setup-qemu-action@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile', '.dockerignore') }}
platforms: ${{ vars.PLATFORMS }}

- name: Setup docker buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3.0.0
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Setup Node
uses: actions/[email protected]
with:
node-version: 16

- name: Install global node modules
run: >
npm i -g
conventional-changelog-cli
conventional-changelog-conventionalcommits
conventional-recommended-bump
git-semver-tags

- name: Eat own dogfood
id: version_info
run: echo "next_version=$(bash entrypoint.sh | cut -f1 -d' ')" >> "$GITHUB_OUTPUT"

- name: Build images and push to Docker Hub
uses: docker/[email protected]
- name: Install project modules
run: npm ci --production

- name: Decide new version
id: bump
run: echo "version=$(node src/cli.js | jq '.next')" >> "$GITHUB_OUTPUT"

- name: Update package version
run: npm version ${{ steps.bump.outputs.version }} --no-git-tag-version

- name: Push new version
run: |
git add package.json package-lock.json
git commit -m "build: updated package with ${{ steps.bump.outputs.version }} [skip ci]"
git push

- name: Push new tag
run: |
git tag ${{ steps.bump.outputs.version }} -m "${{ steps.bump.outputs.version }}"
git push origin ${{ steps.bump.outputs.version }}

- name: Extract meta for image
id: meta
uses: docker/metadata-action@v5
with:
context: .
push: true
platforms: ${{ env.PLATFORMS }}
tags: |
tomerfi/version-bumper:latest
tomerfi/version-bumper:${{ steps.version_info.outputs.next_version }}
build-args: |
VCS_REF=${{ github.sha }}
BUILD_DATE=$(date +'%Y-%m-%d')
VERSION=${{ steps.version_info.outputs.next_version }}
cache-from: |
type=local,src=/tmp/.buildx-cache
ghcr.io/tomerfi/version-bumper:early-access
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Create a release name
images: tomerfi/version-bumper

- name: Set a release name
id: release_name
uses: actions/github-script@v7
with:
script: |
var retval = '${{ steps.version_info.outputs.next_version }}'
var retval = ${{ steps.bump.outputs.version }}
if ('${{ github.event.inputs.title }}') {
retval = retval.concat(' - ${{ github.event.inputs.title }}')
}
core.setOutput('value', retval)

- name: Create a release
id: gh_release
uses: actions/github-script@v7
with:
script: |
const repo_name = context.payload.repository.full_name
const response = await github.request('POST /repos/' + repo_name + '/releases', {
tag_name: '${{ steps.version_info.outputs.next_version }}',
tag_name: '${{ steps.bump.outputs.version }}',
name: '${{ steps.release_name.outputs.value }}',
generate_release_notes: true
})
core.setOutput('html_url', response.data.html_url)

- name: Publish package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish

- name: Push image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: ${{ vars.PLATFORMS }}
tags: |
tomerfi/version-bumper:latest
tomerfi/version-bumper:${{ steps.bump.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
labels: ${{ steps.meta.outputs.labels }}

- name: Update image description on docker hub
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: tomerfi/version-bumper
Loading