Skip to content

Merge pull request #63 from wakatime/major/fix-auto-updates #85

Merge pull request #63 from wakatime/major/fix-auto-updates

Merge pull request #63 from wakatime/major/fix-auto-updates #85

Workflow file for this run

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/*.AppImage
release/latest*.yml
-
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/*.exe
release/latest*.yml
-
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/changelog-action@v1.3.0
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 }}"
})