From b21daf0d29a8604752313c7c5d0be62409a458cc Mon Sep 17 00:00:00 2001 From: Konrad Szwarc Date: Wed, 8 Feb 2023 12:05:54 +0100 Subject: [PATCH] ci: setup release workflow (#200) --- .github/workflows/lint-pr-title.yml | 26 ---------- .github/workflows/main-branch.yml | 25 +++++++++- .github/workflows/pull-request.yml | 73 ++++++++++++++++++++++++++++- CHANGELOG.md | 15 ++++++ docs/SUMMARY.md | 4 ++ docs/contributing.md | 68 +++++++++++++++++++++++++++ package.json | 12 ++++- 7 files changed, 193 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/lint-pr-title.yml create mode 100644 CHANGELOG.md create mode 100644 docs/contributing.md diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml deleted file mode 100644 index 5795b068..00000000 --- a/.github/workflows/lint-pr-title.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: 'Lint PR title' - -on: - pull_request_target: - types: - - opened - - edited - - synchronize - -jobs: - lint: - name: Validate PR title - if: github.repository == 'KonradSzwarc/devscard' - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - types: | - feat - fix - chore - refactor - docs - requireScope: false diff --git a/.github/workflows/main-branch.yml b/.github/workflows/main-branch.yml index 158bdc18..56fed4ae 100644 --- a/.github/workflows/main-branch.yml +++ b/.github/workflows/main-branch.yml @@ -80,7 +80,6 @@ jobs: percy: name: Run Percy check if: github.repository == 'KonradSzwarc/devscard' - needs: deploy runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -111,3 +110,27 @@ jobs: with: urls: ${{ needs.deploy.outputs.deploy-url }} device: all + + release: + name: Create release + if: github.repository == 'KonradSzwarc/devscard' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - name: Get project information + id: projectinfo + uses: gregoranders/nodejs-project-info@v0.0.19 + - name: Get changelog entries + id: changelog_reader + uses: mindsers/changelog-reader-action@v2 + with: + version: ${{ steps.projectinfo.outputs.version }} + - name: Create a new tag and release + uses: ncipollo/release-action@v1 + with: + tag: ${{ steps.changelog_reader.outputs.version }} + name: Release ${{ steps.changelog_reader.outputs.version }} + body: ${{ steps.changelog_reader.outputs.changes }} + allowUpdates: true diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index aa83f877..5fe4ebf0 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -3,8 +3,78 @@ name: Pull Request on: pull_request: branches: [main] + types: [opened, edited, synchronize] jobs: + lint-title: + name: Validate PR title + if: github.repository == 'KonradSzwarc/devscard' + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + requireScope: false + + version: + name: Check package.json version + if: github.repository == 'KonradSzwarc/devscard' + runs-on: ubuntu-latest + steps: + - name: Checkout PR branch + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Get project information + id: projectinfo-current + uses: gregoranders/nodejs-project-info@v0.0.19 + - name: Checkout main branch + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.base.sha }} + - name: Get project information + id: projectinfo-main + uses: gregoranders/nodejs-project-info@v0.0.19 + - name: Get next possible versions + id: semvers + uses: WyriHaximus/github-action-next-semvers@v1 + with: + version: ${{ steps.projectinfo-main.outputs.version }} + - name: Assert correct version bump + uses: nick-fields/assert-action@v1 + with: + expected: ${{ steps.projectinfo-current.outputs.version }} + actual: 'Possible version bumps: ${{ steps.semvers.outputs.patch }}, ${{ steps.semvers.outputs.minor }}, ${{ steps.semvers.outputs.major }}' + comparison: contains + + changelog: + name: Check changelog + if: github.repository == 'KonradSzwarc/devscard' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: Get project information + id: projectinfo + uses: gregoranders/nodejs-project-info@v0.0.19 + - name: Enforce changelog update + uses: dangoslen/changelog-enforcer@v3 + with: + expectedLatestVersion: ${{ steps.projectinfo.outputs.version }} + - name: Get changelog entries + id: changelog_reader + uses: mindsers/changelog-reader-action@v2 + with: + version: ${{ steps.projectinfo.outputs.version }} + - name: Assert correct changelog version + uses: nick-fields/assert-action@v1 + with: + expected: ${{ steps.projectinfo.outputs.version }} + actual: ${{ steps.changelog_reader.outputs.version }} + prettier: name: Run Prettier check runs-on: ubuntu-latest @@ -50,6 +120,7 @@ jobs: percy: name: Run Percy check if: github.repository == 'KonradSzwarc/devscard' + needs: [prettier, typescript, astro, lint-title, version, changelog] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -70,7 +141,7 @@ jobs: preview: name: Create deploy preview - needs: [prettier, typescript, astro] + needs: [prettier, typescript, astro, lint-title, version, changelog] if: github.repository == 'KonradSzwarc/devscard' runs-on: ubuntu-latest outputs: diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..336f1529 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [0.0.1] - 2023-02-07 + +### Workflow + +- ci: add `package.json` version and changelog check to PR workflow. +- ci: setup release workflow on the `main` branch. + +### Docs + +- docs: create changelog file. +- docs: add [contributing page](https://devscard.gitbook.io/docs/contributing). diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 3442c99e..a98237f2 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -5,6 +5,10 @@ - [PDF generation](pdf-generation.md) - [Data transformation](data-transformation.md) +## Project development + +- [Contributing](contributing.md) + ## External links - [Example resume](https://devscard.netlify.app) diff --git a/docs/contributing.md b/docs/contributing.md new file mode 100644 index 00000000..d932602d --- /dev/null +++ b/docs/contributing.md @@ -0,0 +1,68 @@ +# Contributing + +## PR workflow + +### Maintainers + +1. Create a pull request with a title matching the conventional commits convention. +2. Wait for all required checks to pass. +3. If you got a failing Percy check, it's okay as long as your PR was supposed to affect UI. Go to Percy's dashboard and review your visual changes. +4. Assign PR for one (or a few) of the maintainers. +5. Your PR is ready to merge when you have at least one approval and no unresolved threads. +6. Update the date in the changelog to be the current one. +7. Wait for checks to pass again and merge PR. + +### Outside contributors + +In progress... + +## Versioning and changelog + +As this project is used in a fork-based way, each merge to the `main` branch should contain the following: + +- a version bump in `package.json`, +- a new entry in the `CHANGELOG.md`. + +For the `CHANGELOG.md`, each update should look like follows: + +```md +## [] - + +**Related issue:** + +### + + +``` + +### Semantic versioning (\) + +Helps users to determine the changes made between their fork version and the recent version. + +- Patch change (0.0.x) — bug fixes, refactors, docs, and dependency updates. +- Minor change (0.x.0) — features. +- Major change (x.0.0) — not used until we release a stable project version (1.0.0). + +### Change date (\) + +Date when changes were merged written in YYYY-MM-DD format. + +### Related issue (\) + +If the changes are related to a particular issue, provide its URL. + +### Affected components (\) + +Determines what parts of the project were affected by changes. + +- Docs — documentation updates. +- Dependencies — dependency updates. +- Workflow — changes in the development workflow. +- Web — changes related to the web version of the resume. +- Pdf — changes related to the pdf version of the resume. +- Schema — some optional schema properties were added. +- Schema (breaking) — some required schema properties were added, some properties were renamed/removed, data structure changed. + +### Description + +A short description of the changes you made. If your changes require some actions on project forks, remember to describe them. diff --git a/package.json b/package.json index 7af81202..2af63a47 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "devscard", "description": "Template for creating a comprehensive virtual CV for developers.", - "version": "0.0.0", + "version": "0.0.1", "private": true, "engines": { "node": ">=14", @@ -57,5 +57,13 @@ "ts-node": "10.9.1", "type-fest": "3.5.5", "typescript": "4.9.5" - } + }, + "repository": { + "type": "git", + "url": "git+https://github.com/KonradSzwarc/devscard.git" + }, + "bugs": { + "url": "https://github.com/KonradSzwarc/devscard/issues" + }, + "homepage": "https://github.com/KonradSzwarc/devscard#readme" }