From e2e63527314bd5cdda2e10486b6f70922a355f29 Mon Sep 17 00:00:00 2001 From: Stanislav Jakuschevskij Date: Sun, 12 Nov 2023 14:15:55 +0100 Subject: [PATCH] docs: introduce semantic versioning Removed old documentation and added project worklow docs with trunk based development, squash and a semantic versioning guides. Added first version to package*.json and git tag to latest commit. Added monorepo version pattern. Added pipeline step for validating git tag. Added push and deploy conditions for master. Added taggin of docker images. Issue-Ref: #190 --- .github/workflows/backend.yml | 77 ++++++- .github/workflows/cicd-backend.yml | 59 ------ .github/workflows/frontend.yml | 3 - .gitignore | 1 + README.md | 14 +- backend/README.md | 39 +--- backend/docs/course.content.details.md | 121 ----------- backend/docs/course.content.md | 123 ----------- backend/package.json | 2 +- docs/project-workflow.md | 280 +++++++++++++++++++++++++ frontend/package.json | 2 +- package-lock.json | 4 +- 12 files changed, 369 insertions(+), 356 deletions(-) delete mode 100644 .github/workflows/cicd-backend.yml delete mode 100644 backend/docs/course.content.details.md delete mode 100644 backend/docs/course.content.md create mode 100644 docs/project-workflow.md diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 85e756b2c..fa269787f 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -1,4 +1,4 @@ -name: Validate backend. +name: Validate, build, tag, push and deploy backend. on: push: @@ -7,27 +7,96 @@ on: pull_request: branches: [master] paths: ["backend/**"] + types: + - opened + - synchronize jobs: - tests: + validate: runs-on: ubuntu-latest strategy: matrix: - node-version: [18.12.1] + node-version: [18.18.2] steps: - - uses: actions/checkout@v3 + - name: Check out the repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} cache: "npm" + - name: Install backend dependencies run: npm ci -w backend + - name: Prettier check run: npm run -w backend prettier:check + - name: Unit tests run: npm run -w backend unit-test + - name: Integration tests run: npm run -w backend integration-test + + - name: Check if a valid semver git tag is present + run: | + GIT_TAG=$(git describe --tags --exact-match) + # https://github.com/semver/semver/issues/981 + SEMVER_REGEX="^(backend|frontend)\/v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$" + if [[ -z "$GIT_TAG" ]]; then + echo "ERROR: no tag found" + exit 1 + elif ! [[ $GIT_TAG =~ $SEMVER_REGEX ]]; then + echo "ERROR: $GIT_TAG is not a Semver tag with expected prefix" + exit 1 + else + echo "Tag found: $GIT_TAG" + fi + + build-and-push: + needs: validate + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: sjakusch/steam-game-stats-backend + tags: | + type=match,pattern=backend\/v(\d+.\d+.\d+),group=1 + + - name: Build and push + uses: docker/build-push-action@v4 + with: + # push only if master is updated + push: ${{ github.ref == 'refs/heads/master' }} + file: backend/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + deploy: + needs: build-and-push + runs-on: ubuntu-latest + steps: + - name: Deploy on Render + # deploy only if master is updated + if: github.ref == 'refs/heads/master' + env: + deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }} + run: | + curl "$deploy_url" diff --git a/.github/workflows/cicd-backend.yml b/.github/workflows/cicd-backend.yml deleted file mode 100644 index 19373cf2e..000000000 --- a/.github/workflows/cicd-backend.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Validate and deploy backend. - -on: - push: - branches: [master] - paths: ["backend/**"] - -jobs: - tests: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [18.12.1] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: "npm" - - name: Install backend dependencies - run: npm ci -w backend - - name: Prettier check - run: npm run -w backend prettier:check - - name: Unit tests - run: npm run -w backend unit-test - - name: Integration tests - run: npm run -w backend integration-test - - build-and-push: - needs: tests - runs-on: ubuntu-latest - steps: - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v4 - with: - push: true - file: backend/Dockerfile - tags: sjakusch/steam-game-stats-backend:latest - - deploy: - needs: build-and-push - runs-on: ubuntu-latest - steps: - - name: Deploy on Render - if: github.ref == 'refs/heads/master' - env: - deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }} - run: | - curl "$deploy_url" diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 0e56707d8..707ccdafe 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -1,6 +1,3 @@ -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - name: Build frontend. on: diff --git a/.gitignore b/.gitignore index e51e97488..c726ba917 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ build todo.md .mongodb .secrets +local npm-debug.log* yarn-debug.log* diff --git a/README.md b/README.md index c4c983ed4..688427e20 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ # Steam Game Stats -## Project details +## Table of Contents + +1. [Project Details](#project-details) +1. [Development Setup](#development-setup) +1. [Running the Application](#running-the-application) +1. [Debugging](#debugging) +1. [Project Workflow](docs/project-workflow.md) + +## Project Details The Steam Game Stats application collects current steam platform player numbers through the steam api. The historic player numbers are collected by crawling through various online sources. This data is stored in our database, facilitating custom game statistics queries. This allows us to highlight key metrics, such as trending games, personalized game recommendations based on user preferences, most popular games, and other useful insights. Please note that some of these features are still in development. @@ -126,7 +134,3 @@ The debugging configuration is only available for VSCode. You can debug the back For debugging the application in the Docker container select the configuration starting with "`Docker: ...`". This configuration will rebuild the backend image, start the Docker Compose setup with Node.js in debug mode and attach itself to it so that you can set breakpoints in VSCode. When you are finished debugging detach the debugger and the configuration will stop and clean up the containers. The Docker debugging configuration uses the `local-db.env` file for the db setup. For more info on the debugging configuration check the `launch` and `tasks` sections in `.vscode/steam-game-stats.code-workspace`. - -## Creating Issues - -If you would like to create an issue with a template, simply click "Get started" when creating an issue. If you would like to create an issue without a template, click on "Open a blank issue" diff --git a/backend/README.md b/backend/README.md index 1963547dd..b8d0c029f 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1,38 +1,3 @@ -# Project and Course Description +# Steam Game Stats Backend -## Table of Contents - -1. [Introduction](#introduction) -1. [Course Content](#course-content) -1. [Project Details](#project-details) -1. [Architecture](#architecture) - -## Introduction - -This repository contains the backend implementation of a proof of concept application which was developed by Luka Tarman during an intensive full stack web developer course. The purpose of this repository is to demonstrate the skillset of Luka Tarman to potential employers. - -A few words about the student. Luka Tarman is an adaptable and open minded Full Stack Software Developer with a preference for the backend layer. He started with software development due to his extensive experience with computers from a young age, and the fact that he finds great joy in solving technical problems. An up to date CV of Luka can be found here: [CV](https://docs.google.com/document/d/1koF3BsafLKzIdoWY6iUA0Oq-BxEqdRP4ZrKAQ16nwnA/edit?usp=sharing). - -A few words about the course instructor. The instructor is [Stanislav Jakuschevskij](https://www.linkedin.com/in/stanislav-jakuschevskij/). He is a Senior Software Engineer at IBM with a specialization in Blockchain. You can find out more about him on LinkedIn. In case a potential employer for Luka would like to ask questions about the course and Lukas programming education he or she can contact Stanislav via LinkedIn. - -At the time of this writing the application is in a running state and can be demonstrated. If you want to test the application read the main [README.md](../README.md) below. The development continues and new features are constantly introduced. - -## Course Content - -The course content is documented separately. Follow this [link](/docs/course.content.md) for more info. - -## Project Details - -The _Steam Game Stats_ application collects current and historic player numbers of all games available on the steam platform through the steam api and other online sources. The idea behind it is at some point to identify trending "niche" games which are gaining in popularity before they hit the mainstream channels. In its current iteration there is not yet a distinction between niche and mainstream games. But this feature will be added in the future. - -The backend is designed to run 24/7 and collect player numbers of games every day. It provides a REST API for the frontend. - -The frontend shows a list of top trending games with a search functionality for games and a detail view with all collected player numbers in a table. - -## Architecture - -The application uses a 3-tier architecture. - -Container diagram pending: [#91](https://github.com/lukatarman/steam-game-stats-backend/issues/91). - -Data model diagram pending: [#91](https://github.com/lukatarman/steam-game-stats-backend/issues/91). +tba diff --git a/backend/docs/course.content.details.md b/backend/docs/course.content.details.md deleted file mode 100644 index bd3e0b8f5..000000000 --- a/backend/docs/course.content.details.md +++ /dev/null @@ -1,121 +0,0 @@ -# Course Content Details - -## Concepts - -1. [Data Model](#data-model) -1. [Separation of Concerns](#separation-of-concerns) -1. [Single Responsibility Principle](#single-responsibility-principle) -1. [Database Client](#database-client) -1. [Entry Point](#entry-point) - -### Upcomming - -Not all but some of this things are concepts which will be introduced in future. This list is intended to grow. - -1. Web Server -1. REST API -1. Routing -1. Frontend -1. Testing - -## Data Model - -_Blog article: [link](https://www.ibm.com/cloud/learn/data-modeling)._ - -_Detailed Wikipedia description: [link](https://en.wikipedia.org/wiki/Data_model)._ - -### Short Concept Description - -In our application we use JavaScript classes to represent the data model. The data model is a core piece of our application around which the application is build. I think the first sentence in Wikipedia puts it quite well: - -> A data model is an abstract model that organizes elements of data and standardizes how they relate to one another and to the properties of real-world entities. For instance, a data model may specify that the data element representing a car be composed of a number of other elements which, in turn, represent the color and size of the car and define its owner. - -### In Our App - -At the time of this writing: `game.js, players.js`. - -## Separation of Concerns - -_Blog article: [link](https://effectivesoftwaredesign.com/2012/02/05/separation-of-concerns/)._ - -_Detailed Wikipedia description: [link](https://en.wikipedia.org/wiki/Separation_of_concerns)._ - -### Short Concept Description - -Devide a programm in sections where each section is responsible for one specific set of functionality that belongs together. - -**Important: It's not a law. Do it if possible and break it if you must.** - -### In Out App - -One concern is database operations. Taken care by: `database.client.js`. - -One concern is getting data from the steam api. Taken care by: `steam.data.processor.js`. - -One concern is setup and orchestration of the parts of our application. Taken care by: `main.js`. - -One concern is documentation. Taken care by: `README.md` which is this file. - -## Single Responsibility Principle - -_Blog article from the creator: [link](https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html)._ - -_Wikipedia article: [link](https://en.wikipedia.org/wiki/Single-responsibility_principle)._ - -### Short Concept Description - -This one is related to the "Separation of Concerns". Every piece of a program e.g. class, module, function should focus on one concern. - -Nice example from Wikipedia: - -> As an example, consider a module that compiles and prints a report. Imagine such a module can be changed for two reasons. First, the content of the report could change. Second, the format of the report could change. These two things change for different causes. The single-responsibility principle says that these two aspects of the problem are really two separate responsibilities, and should, therefore, be in separate classes or modules. It would be a bad design to couple two things that change for different reasons at different times. - -**Important: It's not a law. Do it if possible and break it if you must.** - -### In Our App - -The database client: `database.client.js`. - -The entry point: `main.js`. - -## Database Client - -A class which encapsulates database operations and setup. So with that we follow the principles outlined above. - -### In Our App - -The database client: `database.client.js`. - -## Entry Point - -Onc central location in the application where all the pieces of the application are initialized and wired together. Can also be called `main`. - -### In Our App - -The database client: `main.js`. - -## Things I've learned - -### Best practice - -Transform data into appropriate format as soon as you receive it. - -### Application Layers - -**Instantiation**: entry point code i.e. setup and configuration, instantiation of all other components and wiring them together - -**Features**::Orchestration: feature related code which orchestrates infrastructure classes, model classes, its own services and if needed utils to implement feature logic - -**Features**::Services: feature related code with uses model classes and utils to perform a feature related task without using any infrastructure - -**Features**::API: routes, controllers and later also services which provide feature functionality which we are making available to the outside world (we use the web-server for that)...so far not much here except game-queries - -**Infrastructure**: code which interfaces to everything external like databases, external APIs like steamAPI and code which creates an interface for other external things to interact with us like the web-server - -**Utils**: reusable code which has no dependencies on any layer but is or can be used everywhere in the project - -**Models**: representation of data goes here, instantiation also mutation/transformation and querying of this data goes here; models can depend on other models or utils but nothing more - -### New Technologies - -Always take some time to research some "best practices" when using a new technology, package, method, etc. diff --git a/backend/docs/course.content.md b/backend/docs/course.content.md deleted file mode 100644 index 695335a6e..000000000 --- a/backend/docs/course.content.md +++ /dev/null @@ -1,123 +0,0 @@ -# Course Content - -This page is a high level overview of the topics which were or are yet to be covered in the intensive full stack web developer course. The language of choice is JavaScript/Node.js. All topics are demonstrated and implemented in the project where possible. - -Each topic lists sub topics without a particular order. - -## Table of Contents - -1. [Requirements](#requirements) -2. [Backend](#backend) -3. [Debugging](#debugging) -4. [Testing](#testing) -5. [Clean Code](#clean-code) -6. [Refactoring](#refactoring) -7. [Architecture](#architecture) -8. [Frontend](#frontend) -9. [Deployment](#deployment) -10. [Agile](#agile) - -## Requirements - -- [x] Brainstorming a development project idea. -- [ ] Identifying and documenting requirements and users. -- [x] Tracking of requirements in Github as Github Issues. - -## Backend - -- [x] Node.js development environment setup. -- [x] Using npm and package.json for package management. -- [x] Working with git feature branches and Github. -- [x] Developing application features. -- [x] Classes and object-oriented programming. -- [x] Working with a data model. -- [x] Working with an HTTP client to access external APIs. -- [x] MongoDB NoSQL database setup. -- [x] Working with a database client. -- [x] Scaleable project directory and file structure. -- [x] Application entry point. -- [x] Dependency injection and when should you use it. -- [x] Setting up a web-server with [_fastify_](fastify.io/). -- [ ] Creating REST API endpoints for HTTP requests: - - [x] GET - - [ ] POST - - [ ] PUT - - [ ] DELETE -- [ ] Authentication. - -## Debugging - -- [x] Debugger setup in Visual Studio Code. -- [x] Debugging in practice - - [x] Breakpoints - - [x] Stepping - - [ ] Watching - - [ ] Call Stack - -## Testing - -- [x] What are tests and why do we need them? -- [x] Unit testing of code without dependencies. -- [x] Unit testing using spies and mocks. -- [x] Clean and readable tests. -- [x] Testability as a marker for clean code. -- [ ] Testing the integration layer. -- [ ] System tests. -- [ ] Unit tests in the frontend. -- [ ] End to end tests. - -## Clean Code - -- [x] Identifiers of clean code. -- [x] Single responsibility principle. -- [x] Separation of concerns. -- [x] Cohesion. -- [x] Naming functions, variables and classes. -- [x] Small functions and classes. - -## Refactoring - -- [x] What is refactoring and why do we need it? -- [x] When should the code be refactored and why? -- [x] Refactoring without tests. -- [x] Common refactorings: - - [x] Extract function, variable and class. - - [x] Renaming. - - [x] Split loop. - - [x] Replace loop with pipeline. - - [x] Decompose conditional. - - [x] Replace nested conditional with guard clauses. - -## Architecture - -- [x] What is software architecture? -- [x] Layered architecture. -- [ ] Modularity. - -## Frontend - -- [x] Benefits of a frontend framework like React. -- [x] Frontend project setup with Node.js. -- [x] Frontend project structure. -- [x] Using a UI library like Bootstrap. -- [x] Connecting the frontend to the backend via HTTP. - -## Deployment - -- [ ] What is application deployment and why do we need it? -- [ ] Deployment Scripts. -- [ ] Local deployment. -- [ ] Deploying into the cloud. -- [ ] Containerizing an application. -- [ ] Automated deployment with Github Actions. - -## Agile - -- [x] What is Agile development and do we need it? -- [ ] Agile ceremonies: - - [ ] Sprints. - - [x] Daily standups. - - [ ] Sprint planing. - - [ ] Sprint review. - - [ ] Scoring poker. - - [ ] Sprint retrospective. diff --git a/backend/package.json b/backend/package.json index 8edd91d82..320f4110e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "backend", - "version": "0.0.1", + "version": "0.37.15", "description": "Steam game stats backend.", "main": "src/main.js", "scripts": { diff --git a/docs/project-workflow.md b/docs/project-workflow.md new file mode 100644 index 000000000..a8605b7d9 --- /dev/null +++ b/docs/project-workflow.md @@ -0,0 +1,280 @@ +# Project Workflow + +This is a living document which outlines the methods, practices and workflows used to deliver the project besides programming itself. + +## Table of Contents + +- [Summary](#summary) +- [Creating Issues](#creating-issues) +- [Trunk Based Development](#trunk-based-development) + - [Rules](#rules) + - [General Workflow](#general-workflow) + - [Push to Trunk Workflow](#push-to-trunk-workflow) + - [Short Lived Branch Workflow](#short-lived-branch-workflow) + - [Before Review](#before-review) + - [After Review](#after-review) + - [Squash in Vim](#squash-in-vim) + - [Rebase with Changes](#rebase-with-changes) + - [TBD Resources](#tbd-resources) +- [Semantic Versioning](#semantic-versioning) + - [Bare Process](#bare-process) + - [NPM Process](#npm-process) + - [Move Tag](#move-tag) + - [SV Resources](#sv-resources) + +## Summary + +The project is being actively developed using: + +- GitHub issues and milestones +- trunk based development +- feature toggles +- non-blocking reviews +- semantic versioning with Git tags +- squash and rebase strategy +- conventional commits + +## Creating Issues + +If you would like to create an issue with a template, simply click "Get started" when creating an issue. If you would like to create an issue without a template, click on "Open a blank issue". + +## Trunk Based Development + +### Rules + +- if you break the build - fix (-forward) immediately +- small changes of 1-3 commits => push to trunk +- bigger changes of > 3 commits => short lived branch + feature toggle +- never force push to master +- rebase when working on trunk +- squash and rebase when working on a branch + +### General Workflow + +Every once in while: + +```bash +# '-p' = prune, cleans up deleted branches +git fetch --all -p +``` + +### Push to Trunk Workflow + +Incorporate your commits using rebase [1]: + +```bash +git fetch +git rebase origin/master +``` + +If there are conflicts [2], resolve, save, stage and run: + +```bash +git rebase --continue +``` + +[1] [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) + +[2] [merge conflicts](https://code.visualstudio.com/docs/sourcecontrol/overview#_understanding-conflicts) + +### Short Lived Branch Workflow + +#### Before Review + +Create a branch, start working and create commits. When ready for the PR and a review "squash and rebase" [3]: + +```bash +# '-i' = interactive rebase +git rebase -i origin/master +``` + +[3] [rewrite history](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History) + +With interactive rebase you can reword and squash multiple commits into one by using short commands like s for squash or r for reword: + +```bash +# example from the git book +# three commits which you rebase + +pick f7f3f6d Change my name a bit +pick 310154e Update README formatting and add blame +pick a5f4a0d Add cat-file +``` + +Squash into one commit: + +```bash +pick f7f3f6d Change my name a bit +s 310154e Update README formatting and add blame +s a5f4a0d Add cat-file +``` + +Will result in one commit the changes of the three, with this message: "Change my name a bit" + +Or squash all three into one and reword if needed with this commands: + +```bash +r f7f3f6d Change my name a bit +s 310154e Update README formatting and add blame +s a5f4a0d Add cat-file +``` + +Saving will prompt a new window where you can change the commit message. + +Push your new squashed and rebased history to remote: + +```bash +git push origin --force +``` + +#### After Review + +When you made changes after a review, first "squash and rebase" from master as shown above and then squash your new local commits: + +```bash +# HEAD~2 indicates how far back (2 commits including the current) you want to rewrite +git rebase -i HEAD~2 +``` + +The same procedure as described above will be started and can be followed to rewrite and squash commits. + +### Squash in Vim + +When squashing using vim, do: + +- place the cursor at the start of the line with the first commit you want to squash +- enter visual block mode (CTRL-V) +- select all the rows you wish squash +- hit 'c' and type 'squash' to replace the 'pick' command +- press ESC to apply that change to all the selected rows + +### Rebase with Changes + +If you encounter this: + +```bash +> git rebase origin/master +error: cannot rebase: You have unstaged changes. +error: Please commit or stash them. +``` + +Do this: + +```bash +git rebase origin/master --autostash +``` + +It is short for: + +```bash +git stash +git fetch --all -p +git rebase origin/master +git stash pop +``` + +### TBD Resources + +- Article: [Git and Trunk Based Development](https://medium.com/contino-engineering/git-to-know-this-before-you-do-trunk-based-development-tbd-476bc8a7c22f) +- Article: [Guide to Trunk Based Development](https://hackernoon.com/a-guide-to-git-with-trunk-based-development-93a350c) +- Article: [Squash Multiple Lines in Vim](https://coderwall.com/p/d6gifw/use-vim-visual-blocks-to-squash-multiple-git-commits) + +## Semantic Versioning + +As a last step before merge to master do: + +- add a tag to package.json +- squash the commits +- add a git tag to the commit +- tag naming pattern is: `/v..` + - e.g. `backend/v0.35.12` + - e.g. `frontend/v0.12.1` +- push commit and tags + +### Bare Process + +```bash +# 1. Commit first +git commit -m "fix: added missing type" + +# 2. Squash +git rebase -i + +# 3. Tags the last commit +git tag -a backend/v0.2.1 -m "backend version 0.2.1" + +# 4. Push to remote with tags +git push origin --follow-tags +``` + +### NPM Process + +```bash +# 1. Commit first +git commit -m "fix: added missing type" + +# 2. Bump version in package*.json, 0.35.12 -> 0.35.13 +npm -w backend version patch + +# 3. Add and commit version +git commit -am "bump package to v0.35.13" + +# 4. Squash +git rebase -i + +# 5. Tag the last commit +git tag -a backend/v0.35.13 -m "backend version 0.35.13" + +# 6. Push to remote with tags +git push origin --follow-tags +``` + +**Note:** npm-version does not git-commit nor git-tag when package in subdirectory. [Bug-Issue #2012](https://github.com/npm/cli/issues/2010) + +### Move Tag + +When having new commits in the branch with a tag and you need to move [1] the tag to the latest or other commit: + +```bash +# Delete the tag on any remote before you push +git push origin :refs/tags/ + +# Replace the tag to reference the most recent commit +git tag -fa + +# Push just the tag to the remote origin OR +git push origin --tags + +# Push commits and tags OR +git push origin --follow-tags + +# Force push if you rebased before +git push origin --force --follow-tags +``` + +[1] [move tag](https://stackoverflow.com/a/8044605) + +### Tag Operations + +```bash +# show all tags +git tag + +# show tag details +git show + +# delete tag +git tag -d +``` + +### Tag Validation + +The pull request pipeline checks in the last step if the latest commit contains a git tag in the [tagging naming pattern](#semantic-versioning) defined above. We are using an extended regex which works in bash to validate the tag as explained here: [semver issue 981](https://github.com/semver/semver/issues/981). The regex provided in the semver spec does not work in bash. + +### SV Resources + +- Spec: [Semver](https://semver.org/) +- Article: [Semantic Versioning with Git Tags](https://travishorn.com/semantic-versioning-with-git-tags-1ef2d4aeede6) +- Docu: [Git-Basics Tagging](https://git-scm.com/book/en/v2/Git-Basics-Tagging) +- Stackoverflow: [Squashed Commits and Git Tags](https://stackoverflow.com/a/54281481) +- Stackoverflow: [Tagging in Monorepos](https://stackoverflow.com/a/56558343) diff --git a/frontend/package.json b/frontend/package.json index 54c1bb3c5..ef66a4d8a 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "0.0.1", + "version": "0.10.0", "description": "Steam game stats frontend.", "main": "index.js", "scripts": { diff --git a/package-lock.json b/package-lock.json index 14344d01c..a2a5d3a04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ ] }, "backend": { - "version": "0.0.1", + "version": "0.37.15", "license": "ISC", "dependencies": { "@fastify/cors": "8.1.0", @@ -48,7 +48,7 @@ } }, "frontend": { - "version": "0.0.1", + "version": "0.10.0", "license": "ISC", "dependencies": { "axios": "0.27.2",