Skip to content

Commit

Permalink
Merge pull request #13 from wakatime/feature/pipeline
Browse files Browse the repository at this point in the history
Create automated pipeline
  • Loading branch information
gandarez authored Aug 22, 2024
2 parents 5caa8e6 + 4a6de17 commit fba5e69
Show file tree
Hide file tree
Showing 15 changed files with 465 additions and 22 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/on_open_issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Open Issue"

on:
issues:
types: [opened]

jobs:
issue-triage:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['triage']
})
34 changes: 34 additions & 0 deletions .github/workflows/on_pull_request_linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Pull Request

on: pull_request

jobs:
lint:
runs-on: ubuntu-latest
steps:
-
name: Lint allowed branch names
uses: lekterable/[email protected]
with:
allowed: |
/^(.+:)?bugfix/.+/i
/^(.+:)?docs?/.+/i
/^(.+:)?feature/.+/i
/^(.+:)?major/.+/i
/^(.+:)?misc/.+/i
-
name: Block fixup/squash commits
uses: xt0rted/block-autosquash-commits-action@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
-
# Run only for release branch
if: ${{ github.base_ref == 'release' }}
name: Check for changelog pattern
uses: gandarez/[email protected]
with:
pr_number: ${{ github.event.number }}
contains: 'Changelog:'
not_contains: '`'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
237 changes: 237 additions & 0 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
name: Build and Release

on:
pull_request:
types: [opened, reopened, ready_for_review, synchronize]
push:
branches: [main]
tags-ignore: ["**"]

jobs:
test-shell-script:
name: Unit Tests Shell Script
runs-on: macos-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
-
name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
ignore_paths: 'bin/tests/libs'
-
name: Setup bats
uses: mig4/setup-bats@v1
with:
bats-version: 1.11.0
-
name: Unit tests
shell: bash
run: bats ./bin/tests

version:
name: Version
concurrency: tagging
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [test-shell-script]
outputs:
semver: ${{ steps.format.outputs.semver }}
semver_tag: ${{ steps.semver-tag.outputs.semver_tag }}
previous_tag: ${{ steps.semver-tag.outputs.previous_tag }}
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Calculate semver tag
id: semver-tag
uses: gandarez/semver-action@master
with:
branching_model: "trunk-based"
prefix: v
main_branch_name: main
-
name: Create tag
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.semver-tag.outputs.semver_tag }}",
sha: context.sha
})
-
name: Format tag
id: format
run: |
echo "${{ steps.semver-tag.outputs.semver_tag }}"
ver=`echo "${{ steps.semver-tag.outputs.semver_tag }}" | sed 's/^v//'`
echo "$ver"
echo "semver=$ver" >> $GITHUB_OUTPUT
build-linux:
name: Build Linux
runs-on: ubuntu-latest
needs: [version]
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
-
name: Update package.json
uses: jaywcjlove/github-action-package@main
with:
version: ${{ needs.version.outputs.semver }}
-
name: Install dependencies
shell: bash
run: npm i
-
name: Build
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: npm run build
-
name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-linux
path: release/wakatime-linux-*.AppImage
-
name: Remove tag if failure
if: ${{ failure() }}
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/${{ needs.version.outputs.semver_tag }}"
})
build-windows:
name: Build Windows
runs-on: windows-latest
needs: [version]
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
-
name: Update package.json
uses: jaywcjlove/github-action-package@main
with:
version: ${{ needs.version.outputs.semver }}
-
name: Install dependencies
shell: bash
run: npm i
-
name: Build
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: npm run build
-
name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-windows
path: release/wakatime-windows-*.exe
-
name: Remove tag if failure
if: ${{ failure() }}
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/${{ needs.version.outputs.semver_tag }}"
})
release:
name: Release
runs-on: ubuntu-latest
needs: [version, build-linux, build-windows]
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
# Run only for main branch
if: ${{ github.ref == 'refs/heads/main' }}
name: Changelog
uses: gandarez/[email protected]
id: changelog-release
with:
current_tag: ${{ github.sha }}
previous_tag: ${{ needs.version.outputs.previous_tag }}
exclude: |
^Merge pull request .*
-
name: Prepare changelog
id: changelog
env:
PRBODY: ${{ steps.changelog-release.outputs.changelog }}
run: |
PRBODY=$(echo "$PRBODY" | tr -d \")
./bin/prepare_changelog.sh "${PRBODY}"
-
name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: artifacts-*
merge-multiple: true
path: release/
-
name: Prepare release assets
run: ./bin/prepare_assets.sh
-
name: "Create release"
uses: softprops/action-gh-release@master
with:
name: ${{ needs.version.outputs.semver_tag }}
tag_name: ${{ needs.version.outputs.semver_tag }}
body: "## Changelog\n${{ steps.changelog.outputs.changelog }}"
target_commitish: ${{ github.sha }}
prerelease: false
draft: false
files: ./release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Remove tag if failure
if: ${{ failure() }}
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/${{ needs.version.outputs.semver_tag }}"
})
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "bin/tests/libs/bats-assert"]
path = bin/tests/libs/bats-assert
url = https://github.com/ztombol/bats-assert.git
60 changes: 60 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Contributing

To contribute to this project please carefully read this document.

## Setup

`desktop-wakatime` is written in [Electron](https://www.electronjs.org/).

Prerequisites:

- We use [bats](https://bats-core.readthedocs.io/en/latest/installation.html) to test shell scripts. (`brew install bats-core`)
- We use the [Node](https://nodejs.org/en/download/package-manager) 22

After cloning, install dependencies with `npm i` then build with `npm run build`.

## Branches

PR branch names must use one of the following prefixes:

- `^major/.+` - `major`
- `^feature/.+` - `minor`
- `^bugfix/.+` - `patch`
- `^docs?/.+` - `build`
- `^misc/.+` - `build`

This branching strategy comes from [semver-action](https://github.com/gandarez/semver-action#branch-names).

We use trunk-based:

- `main` - Default branch. PRs are merged to this branch. GitHub Actions automatically builds releases from this branch.

## Testing and Linting

Coming soon..

## Pull Requests

- Big changes, changes to the API, or changes with backward compatibility trade-offs should be first discussed in the Slack.
- Search [existing pull requests](https://github.com/wakatime/desktop-wakatime/pulls) to see if one has already been submitted for this change. Search the [issues](https://github.com/wakatime/desktop-wakatime/issues?q=is%3Aissue) to see if there has been a discussion on this topic and whether your pull request can close any issues.
- Code formatting should be consistent with the style used in the existing code.
- Don't leave commented out code. A record of this code is already preserved in the commit history.
- All commits must be atomic. This means that the commit completely accomplishes a single task. Each commit should result in fully functional code. Multiple tasks should not be combined in a single commit, but a single task should not be split over multiple commits (e.g. one commit per file modified is not a good practice). For more information see <http://www.freshconsulting.com/atomic-commits>.
- Each pull request should address a single bug fix or feature. This may consist of multiple commits. If you have multiple, unrelated fixes or enhancements to contribute, submit them as separate pull requests.
- Commit messages:
- Use the [imperative mood](http://chris.beams.io/posts/git-commit/#imperative) in the title. For example: "Apply editor.indent preference"
- Capitalize the title.
- Do not end the title with a period.
- Separate title from the body with a blank line. If you're committing via GitHub or GitHub Desktop this will be done automatically.
- Wrap body at 72 characters.
- Completely explain the purpose of the commit. Include a rationale for the change, any caveats, side-effects, etc.
- If your pull request fixes an issue in the issue tracker, use the [closes/fixes/resolves syntax](https://help.github.com/articles/closing-issues-via-commit-messages) in the body to indicate this.
- See <http://chris.beams.io/posts/git-commit> for more tips on writing good commit messages.
- Pull request title and description should follow the same guidelines as commit messages.
- Rebasing pull requests is OK and encouraged. After submitting your pull request some changes may be requested. Prefer using [git fixup](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---fixupltcommitgt) rather than adding orphan extra commits to the pull request, then do a push to your fork. As soon as your PR gets approved one of us will merge it by rebasing and squashing any residuary commits that were pushed while reviewing. This will help to keep the commit history of the repository clean.

## Troubleshooting

Coming soon..

Any question join us on [Slack](https://wakaslack.herokuapp.com/).
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,21 @@ npm run build
Once the build completes, you will find the installer file at the following path:

```shell
/release/[Version]/Wakatime-[Platform]-[Version]-Installer.[Extension]
/release/wakatime-[Platform]-[Arch].[Extension]
```

## Supported Apps

Before requesting support for a new app, first check the [list of supported apps][supported apps].

## Contributing

Pull requests and issues are welcome!
See [Contributing][contributing] for more details.

Made with :heart: by the WakaTime Team.

[api key]: https://wakatime.com/api-key
[dashboard]: https://wakatime.com/
[supported apps]: https://github.com/wakatime/desktop-wakatime/blob/80fba053a1334f22f08c4d0b069be4951d15de95/electron/watchers/apps.ts#L3
[contributing]: CONTRIBUTING.md
Loading

0 comments on commit fba5e69

Please sign in to comment.