💾 Archived View for d.moonfire.us › blog › 2018 › 08 › 27 › mfgames-writing-releases captured on 2022-04-29 at 12:23:20. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-04-28)

➡️ Next capture (2022-06-03)

-=-=-=-=-=-=-

Integrating Semantic Versioning into MfGames Writing

Up a Level

Previous

Next

The final component of this MfGames Writing[1] series is how to integrate semantic releases[2] into the publication process.

1: /tags/mfgames-writing/

2: /blog/2018/08/13/publishing-processes/

If you want to use sentimental versioning[3], then you can probably skip this. I like having automatic versioning because it helps me identify the version that beta readers or an editor has when I go to integrate the changes.

3: http://sentimentalversioning.org/

Series

I appear to be writing a short series of post about the tools I use for publication and writing.

4: /blog/2018/08/13/publishing-processes/

5: /blog/2018/08/21/mfgames-writing-reasons/

6: /blog/2018/08/22/mfgames-writing-init/

7: /blog/2018/08/23/mfgames-writing-content/

8: /blog/2018/08/24/mfgames-writing-docker-and-ci/

9: /blog/2018/08/25/mfgames-writing-formats/

10: /blog/2018/08/26/mfgames-writing-themes/

NPM Packages

Like everything else, we pull in a number of packages from NPM to handle the release process.

$ npm install
npm install \
  @commitlint/cli \
  @commitlint/config-conventional \
  @semantic-release/changelog \
  @semantic-release/git \
  commitizen \
  cz-conventional-changelog \
  husky \
  semantic-release

This is a pretty big and scary list, but there isn't a lot of clean ways to do this. I'll give a brief summary of them.

The `@commitlint` is to make sure we have a consistent commit messages (the `feat:` and `fix:` stuff). This makes sure everything else works smoothly.

The `@semantic-release` packages are to do the release process.

The two packages, `commitizen` and `cz-conventional-changelog`, are used to help guide you through creating the commits if you are unfamiliar with it. When these are installed, you can use `git cz` instead of `git commit`.

Finally, `husky` is used to make sure you follow the commits correctly because it will reject the commit if you don't follow conventions.

Configuration

The bulk of the configuration happens inside `package.json`. This file can get pretty big, so I'm only going to list the differences.

{
    "scripts": {
        "commitmsg": "commitlint -E GIT_PARAMS"
    },
    "release": {
        "branch": "master",
        "message": "chore(release): v${nextRelease.version}\n\n${nextRelease.notes}",
        "verifyConditions": [
            "@semantic-release/changelog",
            "@semantic-release/git"
        ],
        "analyzeCommits": ["@semantic-release/commit-analyzer"],
        "prepare": [
            "@semantic-release/changelog",
            "@semantic-release/npm",
            "@semantic-release/git"
        ],
        "publish": [],
        "success": [],
        "fail": []
    },
    "commitlint": {
        "extends": ["@commitlint/config-conventional"]
    }
}

Updating .gitlab-ci.yml

To actually use this, we have to modify the GitLab setup slightly.

image: dmoonfire/mfgames-writing-js:1.1.1

stages:
    - publish

publish:
    stage: publish
    tags:
        - docker
    script:
        - npm ci
        - npx commitlint --from=master to=CI_BUILD_REF_NAME
        - npx semantic-release
        - npm run build

    artifacts:
        expire_in: 1 week
        paths:
            - "*.pdf"
            - "*.epub"
            - "*.mobi"
            - "*.docx"
            - "*.html"

The two new lines are what does the release process.

- npx commitlint --from=master to=CI_BUILD_REF_NAME
- npx semantic-release

What Does This Give You

So, given the amount of setup, what does this give you? Every time you push up a `feat:` or `fix:`, it will do the following:

That means, every change you do will have a distinct version. With everything else tied together, you could put it in a header and use that to figure out where to make the changes (my writing group gives me 4-12 sets of corrections, frequently overlapping).

This isn't for everyone but I have found it very helpful when working with others.

Metadata

Categories:

Programming

Writing

Tags:

Gitlab

Markdown

MfGames Writing

Semantic Release

Footer

Below are various useful links within this site and to related sites (not all have been converted over to Gemini).

Contact

Biography

Bibliography

Support

Fiction

Fedran

Coding

The Moonfires

Categories

Tags

Privacy

Colophon

License

Mailing List

https://d.moonfire.us/blog/2018/08/27/mfgames-writing-releases/