Archive

Archive for October, 2023

Set up semantic-release to work with bitbucket git

October 23, 2023 Leave a comment

Problem:
Setting up semantic-release to work with bitbucket.

Solution:
Followed the steps in https://medium.com/coding-spaghetti/npm-version-control-using-semantic-release-and-bitbucket-cloud-5294ac6b324b to set up semantic-release.

Install the relevant packages

$ npm install --save-dev semantic-release
$ npm install --save-dev @semantic-release/git @semantic-release/npm
$ less package.json
...
"devDependencies": {
    "@babel/plugin-proposal-private-property-in-object": "^7.21.0",
    "@commitlint/cli": "^17.8.0",
    "@commitlint/config-conventional": "^17.8.0",
    "@semantic-release/git": "^10.0.1",
    "@semantic-release/npm": "^11.0.0",
    "commitlint": "^17.8.0",
    "husky": "^8.0.0",
    "semantic-release": "^22.0.5"
  },
  "release": {
    "repositoryUrl": "https://auth@bitbucket.org/<BITBUCKET_REPO_OWNER>/<BITBUCKET_REPO_SLUG>.git",
    "branches": [
      "main"
    ],
    "plugins": [
      "@semantic-release/commit-analyzer",
      "@semantic-release/npm",
      [
        "@semantic-release/git",
        {
          "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
        }
      ]
    ]
  }
...

note: you need to change and to match your project repo. (If you try and clone your repository, the last two sections of your path make up the repo owner and the repo slug.)

Ex: git clone https://username@bitbucket.org/blahblah/sampleproject.git

the BITBUCKET_REPO_OWNER is blahblah and BITBUCKET_REPO_SLUG is sampleproject

Note:
Bitbucket Personal Access Tokens. Documentation below is for Atlassian’s self-hosted source control tool Bitbucket Server instead of Bitbucket Cloud.
https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html
See https://stackoverflow.com/a/70415364

For Bitbucket Cloud I created an “App Password”
Settings > Personal Bitbucket settings > Access Management > App passwords > Create app password
Under Permissions, Repositories select Write permission

Save the created token. Replace with created token.

export BITBUCKET_TOKEN_BASIC_AUTH=<bitbucket-username>:<token>

Test the settings

$ npx semantic-release --no-ci --dry-run

To start at version v0.1.0
git tag the initial commit. git log to get the commit checksum.

$ git tag -a v0.1.0 -m "v0.1.0" <commit checksum (or part of it)>

Added a post-merge git hook

$ less .git/hooks/post-merge

#!/bin/bash

CURRENT_DIR=$(pwd)
PROJECT_NAME="proj-name"
PROJECT_DIR="lib/proj"

if [[ "${HOME}/${PROJECT_NAME}/${PROJECT_DIR}" == ${CURRENT_DIR}  ]]
then 
    npx semantic-release --no-ci
elif [[ "${HOME}/${PROJECT_NAME}" == ${CURRENT_DIR} ]]
then
    cd ${PROJECT_DIR}
    npx semantic-release --no-ci
    cd -
fi

Source:
Configuration settings for semantic-release
* https://semantic-release.gitbook.io/semantic-release/usage/ci-configuration
* https://medium.com/coding-spaghetti/npm-version-control-using-semantic-release-and-bitbucket-cloud-5294ac6b324b
* https://github.com/semantic-release/git/issues/323

lintian error: source-is-missing

October 13, 2023 Leave a comment

Problem:

I was getting this lintian error for a debian package I was building for a reactjs application.
E: source: source-is-missing build/static/js/787.848931c7.chunk.js
E: source: source-is-missing build/static/js/main.dc45282d.js

Solution

Things I tried to “handle” the lintian error.

  • I added the missing files to /missing-sources folder.
  • Now the error reads

    E: source: source-is-missing debian/missing-sources/787.848931c7.chunk.js
    E: source: source-is-missing debian/missing-sources/main.dc45282d.js

    I was lost as to why lintian was now reporting this. As per this https://sources.debian.org/src/lintian/2.104.0/mail-templates/source-is-missing/

    In order to solve this problem, you could:
    1. add the source files to “debian/missing-sources” directory.
    2. repack the origin tarball and add the missing source files to it.

    Both ways satisfy the requirement to ship all source code. The second option
    might be preferable due to the following reasons [2]:
    – Upstream can do it too and you could even supply a patch to them, thus
    fulfilling our social contract [3], see particularly ยง2.
    – If source and non-source are in different locations, ftpmasters may
    miss the source and (needlessly) reject the package.
    – The source isn’t duplicated in every .diff.gz/.debian.tar.* (though
    this only really matters for larger sources).

    the relevant file were in debian/missing-sources as well as my package.tar file. So I was left with no option but to ignore the error.

  • I then opted to keep the files in missing-sources folder but ignore the debian/missing-sources error above by adding it to debian/.lintian-overrides, but the lintian error persisted.
  • $ less <package-name>.lintian-overrides
    
    <package-name>: initial-upload-closes-no-bugs
    <package-name>: source-is-missing debian/missing-sources/787.848931c7.chunk.js
    <package-name>: source-is-missing debian/missing-sources/main.dc45282d.js
    

    There was no change in the error. The override provided was not matching the error.

  • I then tried to override the source-is-missing errors by adding them to debian/source/lintian-overrides. This worked.
  • $ less debian/source/lintian-overrides
    
    <package-name> source: source-is-missing debian/missing-sources/787.848931c7.chunk.js
    <package-name> source: source-is-missing debian/missing-sources/main.dc45282d.js
    

    In Summary

    1. Add the files to debian/missing-sources
    2. Keep .lintian-overrides
    3. Use debian/sources/lintias-overrides to ignore/match source errors.

    Extra

    Trying to add the js files in debian/source folder just resulted in more lintian errors

    E: <package-name> source: unknown-file-in-debian-source 787.848931c7.chunk.js
    E: <package-name> source: unknown-file-in-debian-source main.dc45282d.js
    
    Categories: debian Tags: , ,