Skip to content
This repository has been archived by the owner on Apr 11, 2022. It is now read-only.

Commit

Permalink
Release automation (#22)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
shiipou and alexesprit authored May 16, 2020
1 parent 3fb9e44 commit 3589118
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 113 deletions.
23 changes: 23 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions .github/workflows/github_release_automation.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions .github/workflows/github_release_link.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
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
29 changes: 29 additions & 0 deletions .github/workflows/test_github_action.yml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 0 additions & 55 deletions .github/workflows/test_github_action_latest.yml

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/test_github_action_master.yml

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
message=":bookmark: Release v%s"
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 3589118

Please sign in to comment.