Skip to content

Task/1.1.0

Task/1.1.0 #139

Workflow file for this run

name: CI Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.18.0'
- name: Install dependencies
run: npm ci
- name: Build the project
run: npm run build
- name: Set up QEMU for multi-arch
uses: docker/setup-qemu-action@v3
with:
platforms: linux/arm64
- name: Build SEA for Alpine amd64
run: docker run --rm --platform linux/amd64 -v "$PWD":/app -w /app node:20.18.0-alpine ./scripts/generate-sea.sh ./pkg/dclint-alpine-amd64
- name: Build SEA for Bullseye amd64
run: docker run --rm --platform linux/amd64 -v "$PWD":/app -w /app node:20.18.0-bullseye ./scripts/generate-sea.sh ./pkg/dclint-bullseye-amd64
- name: Build SEA for Alpine arm64
run: docker run --rm --platform linux/arm64 -v "$PWD":/app -w /app node:20.18.0-alpine ./scripts/generate-sea.sh ./pkg/dclint-alpine-arm64
- name: Build SEA for Bullseye arm64
run: docker run --rm --platform linux/arm64 -v "$PWD":/app -w /app node:20.18.0-bullseye ./scripts/generate-sea.sh ./pkg/dclint-bullseye-arm64
- name: Run linter
run: npm run lint
- name: Run tests
run: npm run test:coverage
- name: Report coverage to Codacy
if: github.ref == 'refs/heads/main'
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: wget -qO - https://coverage.codacy.com/get.sh | bash -s -- report -r ./coverage/cobertura-coverage.xml
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
./dist
./bin
./pkg
debug:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
node-version: [18, 20, 22, 23]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: ./
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci --omit=dev
- name: Run debug:bin
run: npm run debug:bin
release:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: ./
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.18.0'
- name: Install dependencies
run: npm ci
- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
# Upload binary files to GitHub Release
- name: Upload Alpine Binary
uses: actions/upload-release-asset@v1
if: steps.release.outputs.new_release == 'true'
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./pkg/dclint-alpine-amd64
asset_name: dclint-alpine-amd64
asset_content_type: application/octet-stream
- name: Upload Bullseye Binary
uses: actions/upload-release-asset@v1
if: steps.release.outputs.new_release == 'true'
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./pkg/dclint-bullseye-amd64
asset_name: dclint-bullseye-amd64
asset_content_type: application/octet-stream
- name: Upload Alpine ARM64 Binary
uses: actions/upload-release-asset@v1
if: steps.release.outputs.new_release == 'true'
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./pkg/dclint-alpine-arm64
asset_name: dclint-alpine-arm64
asset_content_type: application/octet-stream
- name: Upload Bullseye ARM64 Binary
uses: actions/upload-release-asset@v1
if: steps.release.outputs.new_release == 'true'
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./pkg/dclint-bullseye-arm64
asset_name: dclint-bullseye-arm64
asset_content_type: application/octet-stream
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: |
./package.json
./package-lock.json
./CHANGELOG.md
docker:
runs-on: ubuntu-latest
needs: release
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: ./
overwrite: true
- name: Get build arguments
id: vars
run: |
BUILD_DATE=$(date +%Y-%m-%dT%T%z)
BUILD_VERSION=$(awk -F\" '/"version":/ {print $4}' package.json)
BUILD_REVISION=$(git rev-parse --short HEAD)
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV
echo "BUILD_REVISION=$BUILD_REVISION" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build and push the Alpine version
- name: Build and push Alpine version
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/dclint:alpine
${{ secrets.DOCKERHUB_USERNAME }}/dclint:latest-alpine
${{ secrets.DOCKERHUB_USERNAME }}/dclint:${{ env.BUILD_VERSION }}-alpine
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_VERSION=${{ env.BUILD_VERSION }}
BUILD_REVISION=${{ env.BUILD_REVISION }}
target: alpine-version
# Build and push the Scratch version
- name: Build and push Scratch version
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/dclint:latest
${{ secrets.DOCKERHUB_USERNAME }}/dclint:${{ env.BUILD_VERSION }}
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_VERSION=${{ env.BUILD_VERSION }}
BUILD_REVISION=${{ env.BUILD_REVISION }}
target: scratch-version