From 35891185e1ecec28729d38b03cfd3e256c141fab Mon Sep 17 00:00:00 2001 From: Flavien CADET Date: Sat, 16 May 2020 17:24:30 +0200 Subject: [PATCH] Release automation (#22) * Use github workflow to create the tag when use the `npm run release -- major|minor|patch` command * Use automation to create the draft release related with this tag * Create or update the global tag (major version) when the release was published Co-authored-by: alexesprit --- .github/release-drafter.yml | 23 ++++++++ .../workflows/github_release_automation.yml | 47 ++++++++++++++++ .github/workflows/github_release_link.yml | 26 +++++++++ .github/workflows/test_github_action.yml | 29 ++++++++++ .../workflows/test_github_action_latest.yml | 55 ------------------- .../workflows/test_github_action_master.yml | 55 ------------------- .npmrc | 1 + CONTRIBUTING.md | 12 ++++ package-lock.json | 2 +- package.json | 6 +- 10 files changed, 143 insertions(+), 113 deletions(-) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/github_release_automation.yml create mode 100644 .github/workflows/github_release_link.yml create mode 100644 .github/workflows/test_github_action.yml delete mode 100644 .github/workflows/test_github_action_latest.yml delete mode 100644 .github/workflows/test_github_action_master.yml create mode 100644 .npmrc diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..c4ab969 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,23 @@ +name-template: 'Release v$NEXT_PATCH_VERSION' +tag-template: 'v$NEXT_PATCH_VERSION' +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🧰 Maintenance' + label: 'maintenance' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +template: | + ## Changes + + $CHANGES + + ## Contributors + $CONTRIBUTORS + diff --git a/.github/workflows/github_release_automation.yml b/.github/workflows/github_release_automation.yml new file mode 100644 index 0000000..a62656e --- /dev/null +++ b/.github/workflows/github_release_automation.yml @@ -0,0 +1,47 @@ +name: Release + +on: + push: + branches: + - master + +jobs: + build: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - id: draft_release + name: Draft Release + uses: toolmantim/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Change tag + env: + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "Get the release name" + output=${{ steps.draft_release.outputs.html_url }} + output=$(hub release -d -f "%T;%U%n" | grep "${output}" | cut -d';' -f1) + echo "${output}" + + echo "Get the package.json version" + version=$(cat package.json | jq '.version') + version=${version//\"} + echo "${version}" + + echo "Edit the version in the release" + hub release edit -m "v${version} 🌈" "${output}" + echo "v${version} 🌈" + + echo "Get the new release tag" + output=$(hub release -d -f "%T;%t%n" | grep "v${version}" | head -n1 | cut -d';' -f 1) + echo "${output}" + + echo "Change the release tag to: v${version}" + content="$(hub release show "${output}")" + hub release delete "${output}" + hub release create --draft=true -m "${content}" "v${version}" + hub release -d diff --git a/.github/workflows/github_release_link.yml b/.github/workflows/github_release_link.yml new file mode 100644 index 0000000..814564e --- /dev/null +++ b/.github/workflows/github_release_link.yml @@ -0,0 +1,26 @@ +name: Link tags + +on: + release: + types: + - published + +jobs: + build: + name: Link latest full tag to latest patch + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - run: | + # Extract the tag of the release + LATEST_TAG=${GITHUB_REF##*/} + # Get the patch version of the tag + tag=$(echo "${LATEST_TAG%.*.*}") + # Create git identity + git config --global user.email "bot@nocturlab.fr" + git config --global user.name "BOT_WORKFLOW" + # Use -f to update the current tag version or create a new + git push --delete origin ${tag} 2> /dev/null | true + git tag -f -m "🔖 Release ${tag}" -a ${tag} + git push --tags diff --git a/.github/workflows/test_github_action.yml b/.github/workflows/test_github_action.yml new file mode 100644 index 0000000..ff67ccb --- /dev/null +++ b/.github/workflows/test_github_action.yml @@ -0,0 +1,29 @@ +name: Tests + +on: + push: + paths: + - 'dist/**.js' + pull_request: + paths: + - 'dist/**.js' + +jobs: + test-ubuntu: + name: Run tests on ${{ matrix.os }} ${{ matrix.v-version }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + v-version: [latest, master, 0.1.27] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up V version latest + uses: ./ + with: + v-version: ${{ matrix.v-version }} + id: v + + - name: Test V is present + run: v version diff --git a/.github/workflows/test_github_action_latest.yml b/.github/workflows/test_github_action_latest.yml deleted file mode 100644 index 3f66f4f..0000000 --- a/.github/workflows/test_github_action_latest.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Test Latest - -on: - push: - paths: - - 'dist/**.js' - pull_request: - paths: - - 'dist/**.js' - -jobs: - test-ubuntu: - name: Test with ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up V version latest - uses: ./ - with: - v-version: latest - id: v - - - name: Test V is present - run: v version - - test-macos: - name: Test on MacOS - runs-on: macos-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up V version latest - uses: ./ - with: - v-version: latest - id: v - - - name: Test V is present - run: v version - - test-windows: - name: Test on Windows - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up V version latest - uses: ./ - with: - v-version: latest - id: v - - - name: Test V is present - run: v version diff --git a/.github/workflows/test_github_action_master.yml b/.github/workflows/test_github_action_master.yml deleted file mode 100644 index fdfc4d3..0000000 --- a/.github/workflows/test_github_action_master.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Test Master - -on: - push: - paths: - - 'dist/**.js' - pull_request: - paths: - - 'dist/**.js' - -jobs: - test-ubuntu: - name: Test with ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up V version master - uses: ./ - with: - v-version: master - id: v - - - name: Test V is present - run: v version - - test-macos: - name: Test on MacOS - runs-on: macos-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up V version master - uses: ./ - with: - v-version: master - id: v - - - name: Test V is present - run: v version - - test-windows: - name: Test on Windows - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up V version master - uses: ./ - with: - v-version: master - id: v - - - name: Test V is present - run: v version diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..5516331 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +message=":bookmark: Release v%s" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f77bcbe..8307ebc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,3 +49,15 @@ Now several cases are possible: Choose the start branch (the one you want to send your changes to) and the end branch (the one you want to send your changes to). Put an understandable name, click on `Assign Yourself` on the right, At the bottom of the description, note the id of your github issue like this: `Related issues: #1` or `Close #1`. + +## Create new Release + +Before releasing a new version make sure you have the local repository up-to-date. So you can use this command: + +```sh +git checkout master && git pull && npm version minor +``` + +- `git checkout` to be sure that we are on master. +- `git pull` to be sure to have the latest changes on master. +- `npm version [major | minor | patch]` to create the new version. `minor` will increment the number at the second position. diff --git a/package-lock.json b/package-lock.json index 7de8798..74e5276 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "setup-vlang-action", - "version": "1.0.0", + "version": "1.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5777070..9c6c07d 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,14 @@ { "name": "setup-vlang-action", - "version": "1.0.0", + "version": "1.1.1", "private": true, "description": "setup vlang action", "main": "src/index.ts", "scripts": { "build": "tsc && ncc build", - "pre-checkin": "npm run build && npm test" + "pre-checkin": "npm run build && npm test", + "postversion": "git push && git push --tags", + "release": "git checkout && npm version" }, "repository": { "type": "git",