Skip to content

Commit

Permalink
ci: automatic release mechanism (#53)
Browse files Browse the repository at this point in the history
* ci: automatic release mechanism

* docs: update CONTRIBUTING.md with conventional commits guidelines

* ci: add CI check that fails if a PR base branch is master

* style: rename check jobs

* ci: npm update

* make pre-release builds only on pull request from release branch to master, not on push

* fix bad artifact name

Co-authored-by: Adam Smelko <adamsmelko1@gmail.com>
  • Loading branch information
michalbali256 and asmelko authored Jul 16, 2020
1 parent 83fdf18 commit 0abf1d8
Show file tree
Hide file tree
Showing 10 changed files with 6,220 additions and 111 deletions.
102 changes: 97 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ jobs:
run: |
chmod +x clients/vscode-hlasmplugin/bin/darwin/language_server
chmod +x clients/vscode-hlasmplugin/bin/linux/language_server
- name: Extract branch name
run: echo ::set-env name=BRANCH::${GITHUB_REF#refs/heads/}
- name: Update version
if: env.BRANCH == 'master' || startsWith(env.BRANCH, 'release')
run: cd clients/vscode-hlasmplugin && npm ci && npx semantic-release --dry-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Package VSIX
run: cd clients/vscode-hlasmplugin/ && npm ci && npm run package
- name: Get VSIX filename
Expand All @@ -154,7 +161,16 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Requirements install
run: apk update && apk add --no-cache linux-headers git g++ cmake util-linux-dev npm ninja pkgconfig openjdk8 maven
run: |
apk update
apk add --no-cache linux-headers git g++ cmake util-linux-dev npm ninja pkgconfig openjdk8 maven
- name: Extract branch name
run: echo ::set-env name=BRANCH::${GITHUB_REF#refs/heads/}
- name: Update version
if: env.BRANCH == 'master' || startsWith(env.BRANCH, 'release')
run: cd clients/vscode-hlasmplugin && npm ci && npx semantic-release --dry-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure
run: mkdir build && cd build && cmake -G Ninja ../
- name: Build
Expand All @@ -166,12 +182,88 @@ jobs:
- name: Get version
run: echo ::set-env name=VERSION::$(node -e "console.log(require('./clients/vscode-hlasmplugin/package.json').version)")
- name: Rename VSIX
run: mv ${{ env.VSIX_FILENAME }} hlasm-language-support-alpine-${{ env.VERSION }}.vsix
run: mv ${{ env.VSIX_FILENAME }} hlasm-language-support-${{ env.VERSION }}-alpine.vsix
- name: Upload VSIX
uses: actions/upload-artifact@v1
with:
name: hlasm-language-support-alpine-${{ env.VERSION }}.vsix
path: hlasm-language-support-alpine-${{ env.VERSION }}.vsix
name: hlasm-language-support-${{ env.VERSION }}-alpine.vsix
path: hlasm-language-support-${{ env.VERSION }}-alpine.vsix



release:
name: Release VSIXs
runs-on: ubuntu-18.04
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'pull_request' && github.base_ref == 'master' && startsWith(github.head_ref, 'release'))
needs: [alpine-VSIX, VSIX]

steps:
- uses: actions/checkout@v1
- name: Update version
run: cd clients/vscode-hlasmplugin && npm ci && npx semantic-release --dry-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get new version
run: echo ::set-env name=VERSION::$(node -e "console.log(require('./clients/vscode-hlasmplugin/package.json').version)")
- name: Download VSIX
uses: actions/download-artifact@v1
with:
name: hlasm-language-support-${{ env.VERSION }}.vsix
path: clients/vscode-hlasmplugin/
- name: Download alpine VSIX
uses: actions/download-artifact@v1
with:
name: hlasm-language-support-${{ env.VERSION }}-alpine.vsix
path: clients/vscode-hlasmplugin/
- name: Rename VSIXs
run: |
cd clients/vscode-hlasmplugin/
mv hlasm-language-support-${{ env.VERSION }}.vsix multi.vsix
mv hlasm-language-support-${{ env.VERSION }}-alpine.vsix alpine.vsix
- name: Commit changes
if: github.event_name == 'push'
run: |
git config --global user.email "actions@github.com"
git config --global user.name "github-actions"
git add CHANGELOG.md clients/vscode-hlasmplugin/package.json clients/vscode-hlasmplugin/CHANGELOG.md
git commit -m "chore: Update version & changelog [skip ci]"
- name: Push changes
if: github.event_name == 'push'
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Release new version
run: cd clients/vscode-hlasmplugin && npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Merge master into development
if: github.event_name == 'push'
run: |
git stash
git fetch
git checkout origin/development
git merge origin/master
cd clients/vscode-hlasmplugin
sed -i 's/"version": "\(.*\)"/"version": "\1-NEXT"/g' package.json
sed -i '2s/^/\n## ****Unreleased****\n/' CHANGELOG.md
git add package.json CHANGELOG.md
git commit -m "chore: Prepare for next development cycle [skip ci]"
- name: Push changes
if: github.event_name == 'push'
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: development

- name: Delete PRs head branches
if: github.event_name == 'push'
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: release-${{ env.VERSION }}

theia-test:
name: Theia Integration Test
Expand All @@ -193,7 +285,7 @@ jobs:
- name: Download VSIX
uses: actions/download-artifact@v2
with:
name: hlasm-language-support-alpine-${{ env.VERSION }}.vsix
name: hlasm-language-support-${{ env.VERSION }}-alpine.vsix
path: clients/vscode-hlasmplugin/plugin/
- name: Run Tests
run: cd clients/vscode-hlasmplugin && npm install && npm run compile && node ./build/bin/theiaTest.js /home/theia/
12 changes: 11 additions & 1 deletion .github/workflows/Test.yml → .github/workflows/Check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,21 @@ jobs:
license-headers:
name: Check license headers
name: License headers
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: Check license headers
run: |
chmod +x cmake/check_license.sh
cmake/check_license.sh
pr-base-check:
name: Master PR check
runs-on: ubuntu-18.04
if: github.event_name == 'pull_request'
steps:
- name: Check, whether PR to master is from a release branch
if: github.base_ref == 'master' && !contains(github.head_ref, 'release')
run: exit 1

Empty file added CHANGELOG.md
Empty file.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ All the activity on the project should begin with defining a new issue that desc

## Contribution acceptance

We follow the [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. Each pull request has to be named according to the specification so it can be squash merged. Allowed commit types are: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `ci`, `chore`.

Each pull request is automatically verified in the following environments (in a GitHub Actions pipeline):

- Windows build with the MSVC compiler
Expand Down
50 changes: 50 additions & 0 deletions clients/vscode-hlasmplugin/.releaserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
branches:
- master
- name: release-+([0-9]).+([0-9]).+([0-9])
prerelease: beta
ci: true
tagFormat: ${version}
plugins:
- - "@semantic-release/commit-analyzer"
- preset: conventionalcommits
- - "@semantic-release/release-notes-generator"
- preset: conventionalcommits
presetConfig:
types:
- type: feat
section: "Features"
hidden: false
- type: fix
section: "Fixes"
hidden: false
- type: docs
section: "Other changes"
hidden: false
- type: style
section: "Other changes"
hidden: false
- type: refactor
section: "Other changes"
hidden: false
- type: perf
section: "Fixes"
hidden: false
- type: test
section: "Other changes"
hidden: false
- type: ci
section: "Other changes"
hidden: false
- type: chore
hidden: true
- - "@semantic-release/exec"
- generateNotesCmd: sh prepare_release.sh ${nextRelease.version} ${branch.name} "${nextRelease.notes}" ${lastRelease.version} ${Date.now()}
- - "@semantic-release/github"
- assets:
- path: "multi.vsix"
label: "hlasm-language-support-${nextRelease.version}.vsix"
name: "hlasm-language-support-${nextRelease.version}.vsix"
- path: "alpine.vsix"
label: "hlasm-language-support-${nextRelease.version}-alpine.vsix"
name: "hlasm-language-support-${nextRelease.version}-alpine.vsix"

2 changes: 1 addition & 1 deletion clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

All notable changes to the HLASM Language Support extension are documented in this file.
## ****Unreleased****

## [0.11.0] - 2020-05-07

Expand Down
Loading

0 comments on commit 0abf1d8

Please sign in to comment.