From 7162ba33ba539bcf4ef5e557d6c61ba3e3c1cb4c Mon Sep 17 00:00:00 2001 From: Mark Skilbeck Date: Tue, 13 Jul 2021 11:57:49 +0100 Subject: [PATCH] No code: add release workflow --- .github/workflows/release.yml | 26 +++++++++++++++++++++++ package.json | 39 +++++++++++++++++++++++++++++++++++ prepare_release.sh | 12 +++++++++++ 3 files changed, 77 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 package.json create mode 100644 prepare_release.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..15f9676 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Release + +on: + push: + branches: + - main + - rc + +jobs: + release: + name: Semantic Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: 12 + - name: Install Semantic Release Dependencies + run: npm install + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npx semantic-release \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..bf2324f --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "simquil-semantic-release", + "version": "1.0.0", + "description": "Encapsulate dependencies needed to use semantic-release", + "dependencies": { + "@semantic-release/exec": "^5.0.0", + "@semantic-release/git": "^9.0.0", + "@semantic-release/gitlab": "^6.0.4", + "conventional-changelog-eslint": "^3.0.8", + "semantic-release": "^17.1.1" + }, + "release": { + "branches": ["main", {"name": "rc", "prerelease": true}], + "plugins": [ + ["@semantic-release/commit-analyzer",{ + "preset": "eslint", + "releaseRules": [ + {"tag": "Breaking", "release": "minor"}, + {"tag": "Update", "release": "patch"}, + {"tag": "Fix", "release": "patch"}, + {"tag": "New", "release": "patch"}, + {"tag": "Upgrade", "release": "patch"} + ] + }], + ["@semantic-release/release-notes-generator", { + "preset": "eslint" + }], + ["@semantic-release/exec",{ + "prepareCmd": "sh prepare_release.sh ${nextRelease.version}" + }], + "@semantic-release/github", + ["@semantic-release/git", { + "assets": ["Cargo.toml"], + "message": "Release v${nextRelease.version} [skip ci]" + }] + ], + "repositoryUrl": "ssh://git@github.com/notmgsk/simquil.git" + } +} \ No newline at end of file diff --git a/prepare_release.sh b/prepare_release.sh new file mode 100644 index 0000000..b953629 --- /dev/null +++ b/prepare_release.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +### This script is called by Semantic Release after determining a new version +### for the package and prior to pushing it back to GitHub + +set -ex + +[[ $1 == "" ]] && echo "usage: $0 " && exit 1 + +# We use sed to bump the version to avoid having to install or use any other tools +sed -i.bak -E "s/^version = \".+\"$/version = \"$1\"/" Cargo.toml +rm Cargo.toml.bak \ No newline at end of file