Skip to content

ci: update workflows config. #229

ci: update workflows config.

ci: update workflows config. #229

Workflow file for this run

name: CI
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm run build
- run: npm run doc
- name: Generate Contributors Images
uses: jaywcjlove/github-action-contributors@main
with:
filter-author: (renovate\[bot\]|renovate-bot|dependabot\[bot\])
output: website/build/CONTRIBUTORS.svg
avatarSize: 42
# - name: Create Linux App
# working-directory: electron/app
# run: npm run dist-linux
- name: Create Tag
id: create_tag
uses: jaywcjlove/create-tag-action@main
with:
package-path: ./website/package.json
- name: get tag version
id: tag_version
uses: jaywcjlove/changelog-generator@main
- name: Deploy Website
uses: peaceiris/actions-gh-pages@v4
with:
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: ${{steps.tag_version.outputs.tag}} ${{ github.event.head_commit.message }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./website/build
- name: Generate Changelog
id: changelog
uses: jaywcjlove/changelog-generator@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
filter-author: (jaywcjlove|小弟调调™|dependabot\[bot\]|Renovate Bot)
filter: (^[\s]+?[R|r]elease)|(^[R|r]elease)
# Create electron static page
- name: Create electron-compliant static resources.
run: npm run electron
- uses: actions/upload-artifact@v4
with:
name: webiste
path: |
website/build/**
outputs:
version: ${{ steps.changelog.outputs.version }}
create_tag_version: ${{ steps.create_tag.outputs.version }}
create_tag_versionNumber: ${{ steps.create_tag.outputs.versionNumber }}
tag: ${{ steps.changelog.outputs.tag }}
successful: ${{steps.create_tag.outputs.successful }}
gh-pages-short-hash: ${{ steps.changelog.outputs.gh-pages-short-hash }}
docker:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install
- run: npm run build
- run: npm run doc
- run: echo "outputs.version - ${{ needs.build.outputs.version }}"
- run: echo "outputs.create_tag_version - ${{ needs.build.outputs.create_tag_version }}"
- run: echo "outputs.create_tag_versionNumber - ${{ needs.build.outputs.create_tag_versionNumber }}"
- run: echo "outputs.successful - ${{ needs.build.outputs.successful }}"
- run: echo "outputs.tag - ${{ needs.build.outputs.tag }}"
# Create Docker Image
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push image:latest
uses: docker/build-push-action@v6
with:
push: true
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ secrets.DOCKER_USER }}/tools:latest
- name: Build and push image:tags
uses: docker/build-push-action@v6
if: needs.build.outputs.successful == true
with:
push: true
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ secrets.DOCKER_USER }}/tools:${{needs.build.outputs.create_tag_versionNumber}}
build_windows:
needs: [build]
runs-on: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install
# run: npm install --build-from-source
run: npm install
- run: npm run hoist
- run: npm run build
# - run: npm run electron
- uses: actions/download-artifact@v4
with:
name: webiste
path: website/build
- name: electron-builder install-app-deps
working-directory: electron/app
run: npm run deps
- run: npm run build:app
- uses: actions/upload-artifact@v4
with:
name: tools-windows
path: |
electron\app\dist\*.exe
build_macos:
needs: [build]
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install
- run: npm run hoist
- run: npm run build
# - run: npm run electron
- uses: actions/download-artifact@v4
with:
name: webiste
path: website/build
- name: electron-builder install-app-deps
working-directory: electron/app
run: npm run deps
- run: npm run build:app
- uses: actions/upload-artifact@v4
with:
name: tools-macos
path: |
electron/app/dist/*.zip
electron/app/dist/*.dmg
- uses: actions/upload-artifact@v4
with:
name: tools-macos-zip
path: |
electron/app/dist/*.zip
build_linux:
needs: [build]
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm install
- run: npm run hoist
- run: npm run build
# - run: npm run electron
- uses: actions/download-artifact@v4
with:
name: webiste
path: website/build
- name: electron-builder install-app-deps
working-directory: electron/app
run: npm run deps
- run: npm run build:app
- uses: actions/upload-artifact@v4
with:
name: tools-linux
path: |
electron/app/dist/*.deb
electron/app/dist/*.rpm
download:
needs: [build, build_windows, build_macos, build_linux]
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/download-artifact@v4
with:
name: tools-linux
path: dist/linux
- uses: actions/download-artifact@v4
with:
name: tools-macos
path: dist/macos
- uses: actions/download-artifact@v4
with:
name: tools-windows
path: dist/windows
- name: Display structure of downloaded files
working-directory: dist
run: ls -R
create_release:
needs: [build, build_windows, build_macos, build_linux]
if: needs.build.outputs.successful
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/download-artifact@v4
with:
name: tools-linux
path: dist/linux
- uses: actions/download-artifact@v4
with:
name: tools-macos
path: dist/macos
- uses: actions/download-artifact@v4
with:
name: tools-windows
path: dist/windows
- name: Display structure of downloaded files
working-directory: dist
run: ls -R
- name: Generate Changelog
id: changelog
uses: jaywcjlove/changelog-generator@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
filter-author: (jaywcjlove|小弟调调™|dependabot\[bot\]|Renovate Bot)
filter: (^[\s]+?[R|r]elease)|(^[R|r]elease)
- name: Create Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ needs.build.outputs.create_tag_version }}
tag: ${{ needs.build.outputs.create_tag_version }}
artifacts: "dist/linux/*.rpm,dist/linux/*.deb,dist/macos/*.zip,dist/macos/*.dmg,dist/windows/*.exe"
body: |
[![Buy me a coffee](https://img.shields.io/badge/Buy%20me%20a%20coffee-048754?logo=buymeacoffee)](https://jaywcjlove.github.io/#/sponsor) [![Docker Image Version (latest by date)](https://img.shields.io/docker/v/wcjiang/tools)](https://hub.docker.com/r/wcjiang/tools) [![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/wcjiang/tools)](https://hub.docker.com/r/wcjiang/tools) [![Docker Pulls](https://img.shields.io/docker/pulls/wcjiang/tools)](https://hub.docker.com/r/wcjiang/tools)
Documentation ${{ needs.build.outputs.create_tag_version }}: https://raw.githack.com/jaywcjlove/tools/${{ needs.build.outputs.gh-pages-short-hash }}/index.html
Comparing Changes: ${{ steps.changelog.outputs.compareurl }}
${{ steps.changelog.outputs.changelog }}
```bash
docker pull wcjiang/tools:${{needs.build.outputs.create_tag_versionNumber}}
```
```bash
docker run --name tools --rm -d -p 9666:3000 wcjiang/tools:${{ needs.build.outputs.create_tag_versionNumber }}
# Or
docker run --name tools -itd -p 9666:3000 wcjiang/tools:${{ needs.build.outputs.create_tag_versionNumber }}
```
Visit the following URL in your browser
```bash
http://localhost:9666/
```
roll_back:
if: failure()
needs: [build, create_release]
runs-on: ubuntu-latest
timeout-minutes: 4
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: dev-drprasad/delete-tag-and-release@v1.0
if: needs.build.outputs.successful
with:
delete_release: true
repo: jaywcjlove/tools
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_name: '${{ needs.build.outputs.create_tag_version }}'