From e8769e22b5328088e8c546f653ccd92b925fcc01 Mon Sep 17 00:00:00 2001 From: belodetek <2033996+ab77@users.noreply.github.com> Date: Sun, 21 Aug 2022 11:27:37 -0700 Subject: [PATCH] Run pre-built Docker image Co-authored-by: Page- Change-type: patch --- .github/workflows/testing.yml | 22 ---------- action.yml | 2 +- repo.yml | 10 ----- versionist.conf.js | 79 +++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/testing.yml delete mode 100644 repo.yml create mode 100644 versionist.conf.js diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml deleted file mode 100644 index 321a9aa8..00000000 --- a/.github/workflows/testing.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Unit Tests - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - nodeJS: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Use Node.js 12.x - uses: actions/setup-node@v2 - with: - node-version: 12.x - - name: Test preperation - run: sed -i '/"balena-cli":/d' package.json - - name: Install dependencies - run: npm ci - - run: npm test diff --git a/action.yml b/action.yml index 2ce11090..8be12cf1 100644 --- a/action.yml +++ b/action.yml @@ -62,7 +62,7 @@ outputs: description: 'Version of the release built' runs: using: 'docker' - image: 'Dockerfile' + image: 'docker://ghcr.io/balena-io/deploy-to-balena-action:latest' env: BALENA_TOKEN: ${{ inputs.balena_token }} BALENA_URL: ${{ inputs.environment }} diff --git a/repo.yml b/repo.yml deleted file mode 100644 index b97d729c..00000000 --- a/repo.yml +++ /dev/null @@ -1,10 +0,0 @@ -type: node -release: github -publishMetadata: true -upstream: - - repo: 'balena-sdk' - url: 'https://github.com/balena-io/balena-sdk' - module: '@balena/balena-sdk' - - repo: 'balena-cli' - url: 'https://github.com/balena-io/balena-cli' - module: '@balena/balena-cli' diff --git a/versionist.conf.js b/versionist.conf.js new file mode 100644 index 00000000..8046f177 --- /dev/null +++ b/versionist.conf.js @@ -0,0 +1,79 @@ +'use strict'; + +const execSync = require('child_process').execSync; +const yaml = require('yaml'); +const fs = require('fs'); +const regex = /(docker:\/\/ghcr.io\/balena-io\/deploy-to-balena-action):.*/i; + +const getAuthor = (commitHash) => { + return execSync(`git show --quiet --format="%an" ${commitHash}`, { + encoding: 'utf8' + }).replace('\n', ''); +}; + +const isIncrementalCommit = (changeType) => { + return Boolean(changeType) && changeType.trim().toLowerCase() !== 'none'; +}; + +module.exports = { + // This setup allows the editing and parsing of footer tags to get version and type information, + // as well as ensuring tags of the type 'v..' are used. + // It increments in a semver compatible fashion and allows the updating of NPM package info. + editChangelog: true, + parseFooterTags: true, + getGitReferenceFromVersion: 'v-prefix', + incrementVersion: 'semver', + updateVersion: (cwd, version, callback) => { + const packageFile = `${cwd}/package.json`; + const packageData = require(packageFile); + packageData.version = version; + fs.writeFileSync(packageFile, JSON.stringify(packageData, null, 2)); + const actionYml = `${cwd}/action.yml`; + const action = yaml.parse(fs.readFileSync(actionYml, 'utf8')); + action.runs.image = action.runs.image.replace(regex, `$1:v${version}`); + fs.writeFileSync(actionYml, yaml.stringify(action)); + }, + + // Always add the entry to the top of the Changelog, below the header. + addEntryToChangelog: { + preset: 'prepend', + fromLine: 6 + }, + + // Only include a commit when there is a footer tag of 'change-type'. + // Ensures commits which do not up versions are not included. + includeCommitWhen: (commit) => { + return isIncrementalCommit(commit.footer['change-type']); + }, + + // Determine the type from 'change-type:' tag. + // Should no explicit change type be made, then no changes are assumed. + getIncrementLevelFromCommit: (commit) => { + if (isIncrementalCommit(commit.footer['change-type'])) { + return commit.footer['change-type'].trim().toLowerCase(); + } + }, + + // If a 'changelog-entry' tag is found, use this as the subject rather than the + // first line of the commit. + transformTemplateData: (data) => { + data.commits.forEach((commit) => { + commit.subject = commit.footer['changelog-entry'] || commit.subject; + commit.author = getAuthor(commit.hash); + }); + + return data; + }, + + template: [ + '## v{{version}} - {{moment date "Y-MM-DD"}}', + '', + '{{#each commits}}', + '{{#if this.author}}', + '* {{capitalize this.subject}} [{{this.author}}]', + '{{else}}', + '* {{capitalize this.subject}}', + '{{/if}}', + '{{/each}}' + ].join('\n') +};