Skip to content

Package Builder

Package Builder #272

name: Package Builder
on:
workflow_dispatch:
inputs:
pkgName:
description: The name of the package.
required: true
pkgVersion:
description: The version of the package.
required: false
env:
PACKAGE_URN: ${{ github.event.inputs.pkgName }}
PACKAGE_VERSION: ${{ github.event.inputs.pkgVersion }}
jobs:
generate-workdir:
name: Generate the workdir
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: "Setup NodeJs"
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: "Cache the dependencies"
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node18-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node18-
- name: "Install dependencies"
run: npm ci --no-progress
- name: "Generate the workdir"
run: npm run generate:workdir -- -p "${{ env.PACKAGE_URN }}"
- name: "Tar tmp directory"
run: |
mkdir -p .tmp
tar cf tmp.tar .tmp
working-directory: .workdir
- name: "Upload the workdir"
uses: actions/upload-artifact@v3
with:
name: workdir
path: |
.workdir/tmp.tar
.workdir/source
.workdir/library.yaml
generate-distribution:
name: Generate the distribution
runs-on: ubuntu-22.04
container: #docker://thibaultmorin/plantuml-generator:1.10
image: docker://thibaultmorin/plantuml-generator:1
options: --user root
needs: [ generate-workdir ]
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- uses: actions/download-artifact@v3
with:
name: workdir
- name: "Provide the .tmp directory"
run: tar xf tmp.tar
- name: "Generate the distribution"
run: plantuml-generator library generate library.yaml --urn "${{ env.PACKAGE_URN }}" --clean-urn "${{ env.PACKAGE_URN }}"
- name: "Tar distribution directory"
run: tar cf distribution.tar distribution
- name: "Upload the distribution"
uses: actions/upload-artifact@v3
with:
name: distribution
path: distribution.tar
push-distribution:
name: Push the distribution
runs-on: ubuntu-22.04
needs: [ generate-distribution ]
steps:
- uses: actions/checkout@v3
- name: "Delete distribution"
run: rm -Rf distribution
- uses: actions/download-artifact@v3
with:
name: distribution
- name: "Provide the distribution directory"
run: |
tar xf distribution.tar
rm distribution.tar
- run: ls -hla
- name: "Format the commit message"
uses: haya14busa/action-cond@v1
id: commit_message
with:
cond: "${{ env.PACKAGE_VERSION != null && env.PACKAGE_VERSION != '' }}"
if_true: "feat(${{ env.PACKAGE_URN }}): upgrade to ${{ env.PACKAGE_VERSION }}"
if_false: "feat(${{ env.PACKAGE_URN }}): refresh the package"
- name: "Commit changes"
run: |
git config --local user.email "[email protected]"
git config --local user.name "package_builder"
git add -A
git commit -m "${{ steps.commit_message.outputs.value }}"
- name: "Push the changes"
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}