Skip to content

[Release] Build 66 of branch main by @NGPixel #66

[Release] Build 66 of branch main by @NGPixel

[Release] Build 66 of branch main by @NGPixel #66

Workflow file for this run

name: Build and Release
run-name: ${{ inputs.deploy == 'Skip' && '[Dev]' || '[Release]' }} Build ${{ github.run_number }} of branch ${{ github.ref_name }} by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
datatrackerRef:
description: 'Datatracker API Spec Repo Ref'
required: true
type: string
default: 'feat/rpc-api'
deploy:
description: 'Deploy to K8S'
default: 'Skip'
required: true
type: choice
options:
- Skip
- Staging Only
- Staging + Prod
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# -----------------------------------------------------------------
# BUILD
# -----------------------------------------------------------------
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
outputs:
pkg_version: ${{ steps.buildvars.outputs.pkg_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: false
path: red
- uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: false
repository: ietf-tools/datatracker
ref: ${{ inputs.datatrackerRef }}
path: datatracker
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Get Next Version
id: semver
if: ${{ inputs.deploy == 'Staging Only' || inputs.deploy == 'Staging + Prod' }}
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: main
skipInvalidTags: true
patchList: fix, bugfix, perf, refactor, test, tests, chore
- name: Get Dev Version
if: ${{ inputs.deploy == 'Skip' }}
id: semverdev
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: main
skipInvalidTags: true
noVersionBumpBehavior: 'current'
noNewCommitBehavior: 'current'
- name: Set Release Flag
if: ${{ inputs.deploy == 'Staging Only' || inputs.deploy == 'Staging + Prod' }}
run: |
echo "IS_RELEASE=true" >> $GITHUB_ENV
- name: Set Build Variables
id: buildvars
run: |
if [[ $IS_RELEASE ]]; then
echo "Using AUTO SEMVER mode: ${{ steps.semver.outputs.nextStrict }}"
echo "pkg_version=${{ steps.semver.outputs.nextStrict }}" >> $GITHUB_OUTPUT
echo "::notice::Release ${{ steps.semver.outputs.nextStrict }} created using branch $GITHUB_REF_NAME"
else
echo "Using DEV mode: ${{ steps.semverdev.outputs.nextMajorStrict }}.0.0-dev.$GITHUB_RUN_NUMBER"
echo "pkg_version=${{ steps.semverdev.outputs.nextMajorStrict }}.0.0-dev.$GITHUB_RUN_NUMBER" >> $GITHUB_OUTPUT
echo "::notice::Non-production build ${{ steps.semverdev.outputs.nextMajorStrict }}.0.0-dev.$GITHUB_RUN_NUMBER created using branch $GITHUB_REF_NAME"
fi
- name: Set package.json version
uses: KageKirin/[email protected]
with:
file: red/client/package.json
version: ${{ steps.buildvars.outputs.pkg_version }}
- name: Generate red-api spec
working-directory: ./datatracker
run: |
cat > doit.bash <<EOF
echo "Creating and activating virtual environment..."
python -mvenv venv
source venv/bin/activate
echo "Installing requirements..."
pip install -r requirements.txt
echo "Generating OpenAPI spec..."
touch ietf/settings_local.py
ietf/manage.py spectacular --skip-checks > red-api.yml
EOF
docker run --rm --volume .:/workspace ghcr.io/ietf-tools/datatracker-app-base:latest /bin/bash -e doit.bash
mv red-api.yml ..
- name: Generate API client
working-directory: ./
run: |
npx apigen-ts ./red-api.yml --inline-enums --parse-dates ./red-client.ts
cp red-client.ts ./red/client/generated/
- name: Archive red-api client
uses: actions/upload-artifact@v4
with:
name: red-api
path: |
red-api.yml
red-client.ts
# Build dev instead of production until we sort out how to do prerendering, which needs a live datatracker
- name: NPM Install + Build Site
run: |
npm ci
npm run build:dev
working-directory: ./red/client
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Image
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_SUMMARY: false
with:
context: ./red/
file: ./red/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/ietf-tools/red:${{ steps.buildvars.outputs.pkg_version }}
- name: Create Draft Release
if: ${{ env.IS_RELEASE == 'true' }}
uses: ncipollo/[email protected]
with:
prerelease: true
draft: false
owner: ietf-tools
repo: red
commit: ${{ github.sha }}
tag: ${{ steps.semver.outputs.nextStrict }}
name: ${{ steps.semver.outputs.nextStrict }}
body: '*pending*'
token: ${{ github.token }}
- name: Generate CHANGELOG
id: changelog
uses: Requarks/changelog-action@v1
if: ${{ env.IS_RELEASE == 'true' }}
with:
token: ${{ github.token }}
fromTag: ${{ steps.semver.outputs.nextStrict }}
toTag: ${{ steps.semver.outputs.current }}
writeToFile: false
- name: Finalize Release
if: ${{ env.IS_RELEASE == 'true' }}
uses: ncipollo/[email protected]
with:
allowUpdates: true
makeLatest: true
draft: false
owner: ietf-tools
repo: red
tag: ${{ steps.semver.outputs.nextStrict }}
name: ${{ steps.semver.outputs.nextStrict }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ github.token }}
# -----------------------------------------------------------------
# STAGING
# -----------------------------------------------------------------
staging:
name: Deploy to Staging
if: ${{ !failure() && !cancelled() && (inputs.deploy == 'Staging Only' || inputs.deploy == 'Staging + Prod') }}
needs: [build]
runs-on: ubuntu-latest
environment:
name: staging
env:
PKG_VERSION: ${{needs.build.outputs.pkg_version}}
steps:
- name: Deploy to staging
uses: the-actions-org/workflow-dispatch@v4
with:
workflow: deploy.yml
repo: ietf-tools/infra-k8s
ref: main
token: ${{ secrets.GH_INFRA_K8S_TOKEN }}
inputs: '{ "environment":"${{ secrets.GHA_K8S_CLUSTER }}", "app":"red", "appVersion":"${{ env.PKG_VERSION }}", "remoteRef":"${{ github.sha }}" }'
wait-for-completion: true
wait-for-completion-timeout: 10m
wait-for-completion-interval: 30s
display-workflow-run-url: false
# -----------------------------------------------------------------
# PROD
# -----------------------------------------------------------------
prod:
name: Deploy to Production
if: ${{ !failure() && !cancelled() && (inputs.deploy == 'Staging + Prod') }}
needs: [build, staging]
runs-on: ubuntu-latest
environment:
name: production
env:
PKG_VERSION: ${{needs.build.outputs.pkg_version}}
steps:
- name: Deploy to production
uses: the-actions-org/workflow-dispatch@v4
with:
workflow: deploy.yml
repo: ietf-tools/infra-k8s
ref: main
token: ${{ secrets.GH_INFRA_K8S_TOKEN }}
inputs: '{ "environment":"${{ secrets.GHA_K8S_CLUSTER }}", "app":"red", "appVersion":"${{ env.PKG_VERSION }}", "remoteRef":"${{ github.sha }}" }'
wait-for-completion: true
wait-for-completion-timeout: 10m
wait-for-completion-interval: 30s
display-workflow-run-url: false