Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(publish): add publishing options #5

Merged
merged 4 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
inputs:
projects:
required: true
description: "Comma-separated list of projects to build"
description: 'Comma-separated list of projects to build'
type: string

jobs:
Expand Down Expand Up @@ -35,4 +35,4 @@ jobs:
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
file: ${{ matrix.project }}/Dockerfile
file: ${{ matrix.project }}/Dockerfile
113 changes: 113 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Docker Release

on:
workflow_call:
inputs:
projects:
required: true
description: 'Comma-separated list of projects to release'
type: string
version:
required: true
description: 'Version of the Docker release'
type: string
docker-registry:
required: true
description: 'Docker registry to push the Docker image to'
type: string
github-registry:
required: false
description: 'Whether to push the image to the GitHub registry'
type: string
env-file:
required: false
description: 'Contents of the ENV file to use during building, should only be used as an exception.'
type: string
docker-paths:
required: true
description: 'Comma-separated list of Docker paths corresponding to each project'
type: string
secrets:
REGISTRY_USERNAME:
required: true
REGISTRY_PASSWORD:
required: true

jobs:
release:
runs-on: ubuntu-latest
if: ${{ inputs.version != '' }}
permissions:
packages: write
container:
image: docker:dind
strategy:
matrix:
project: ${{ fromJson(inputs.projects) }}
docker-path: ${{ fromJson(inputs.docker-paths) }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up environment
if: ${{ inputs.env-file != '' }}
env:
ENV_FILE: ${{ inputs.env-file }}
run: |
echo "${ENV_FILE}" > ${{ matrix.project }}/.env

- name: Extract Image Name
id: extract
run: |
input="${{ matrix.docker-path }}"
result="${input#*/}"
echo "{name}={part}" >> $result

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Registry (GitHub)
if: ${{ inputs.github-registry == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image (GitHub)
if: ${{ inputs.github-registry == 'true' }}
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
tags: |
ghcr.io/gewis/${{ steps.extract.outputs.part }}:latest
ghcr.io/gewis/${{ steps.extract.outputs.part }}:${{inputs.version}}
cache-from: type=gha
cache-to: type=gha,mode=max
file: ${{ matrix.project }}/Dockerfile

- name: Login to Registry (Custom)
uses: docker/login-action@v3
with:
registry: ${{ inputs.docker-registry }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Build and Push Docker Image (Custom)
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
tags: |
${{ inputs.docker-registry }}/${{ matrix.docker-path }}:latest
${{ inputs.docker-registry }}/${{ matrix.docker-path }}:${{ inputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: ${{ matrix.project }}/Dockerfile
96 changes: 96 additions & 0 deletions .github/workflows/lint-and-build-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: TypeScript Lint and Build with NPM

on:
workflow_call:
inputs:
working-directory:
required: false
type: string
default: '.'
node-version:
required: false
type: string
default: '20.x'
artifact-name:
required: false
type: string
description: 'Name of artifact to use'
artifact-path:
required: false
type: string
description: 'Path to place artifact'
prepare-command:
required: false
type: string
description: 'Command to run directly after checkout.'
cleanup-command:
required: false
type: string
description: 'Command to run after the workflow (even if failed).'
lint:
type: boolean
description: 'Run the lint step.'
default: true
format:
type: boolean
description: 'Run the format step.'
default: false
test:
type: boolean
description: 'Run the test step.'
default: false
build:
type: boolean
description: 'Run the build step.'
default: true

jobs:
npm-steps:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: ${{ inputs.artifact-path }}
if: ${{ inputs.artifact-name != '' }}

- name: Prepare
run: ${{ inputs.prepare-command }}
if: ${{ inputs.prepare-command != '' }}

- name: Set Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

- name: Install dependencies
working-directory: ${{ inputs.working-directory }}
run: npm install

- name: Lint the project
working-directory: ${{ inputs.working-directory }}
run: npm run lint
if: ${{ inputs.lint }}

- name: Format the project
working-directory: ${{ inputs.working-directory }}
run: npm run format
if: ${{ inputs.format }}

- name: Test the project
working-directory: ${{ inputs.working-directory }}
run: npm run test
if: ${{ inputs.test }}

- name: Build the project
working-directory: ${{ inputs.working-directory }}
run: npm run build
if: ${{ inputs.build }}

- name: Cleanup
run: ${{ inputs.cleanup-command }}
if: ${{ inputs.cleanup-command != '' && always() }}
106 changes: 106 additions & 0 deletions .github/workflows/lint-and-build-yarn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: TypeScript Lint and Build with Yarn

on:
workflow_call:
inputs:
working-directory:
required: false
type: string
default: '.'
node-version:
required: false
type: string
default: '20.x'
artifact-name:
required: false
type: string
description: 'Name of artifact to use'
artifact-path:
required: false
type: string
description: 'Path to place artifact'
prepare-command:
required: false
type: string
description: 'Command to run directly after checkout.'
cleanup-command:
required: false
type: string
description: 'Command to run after the workflow (even if failed).'
lint:
type: boolean
description: 'Run the lint step.'
default: true
format:
type: boolean
description: 'Run the format step.'
default: false
test:
type: boolean
description: 'Run the test step.'
default: false
build:
type: boolean
description: 'Run the build step.'
default: true

jobs:
yarn-steps:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: ${{ inputs.artifact-path }}
if: ${{ inputs.artifact-name != '' }}

- name: Prepare
run: ${{ inputs.prepare-command }}
if: ${{ inputs.prepare-command != '' }}

- name: Set Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

- name: Install dependencies
uses: borales/actions-yarn@v4
with:
cmd: install
dir: ${{ inputs.working-directory }}

- name: Lint the project
uses: borales/actions-yarn@v4
with:
cmd: lint
dir: ${{ inputs.working-directory }}
if: ${{ inputs.lint }}

- name: Format the project
uses: borales/actions-yarn@v4
with:
cmd: format
dir: ${{ inputs.working-directory }}
if: ${{ inputs.format }}

- name: Test the project
uses: borales/actions-yarn@v4
with:
cmd: test
dir: ${{ inputs.working-directory }}
if: ${{ inputs.test }}

- name: Build the project
uses: borales/actions-yarn@v4
with:
cmd: build
dir: ${{ inputs.working-directory }}
if: ${{ inputs.build }}

- name: Cleanup
run: ${{ inputs.cleanup-command }}
if: ${{ inputs.cleanup-command != '' && always() }}
Loading
Loading