Skip to content

Feat/integrate api topic page (#57) #79

Feat/integrate api topic page (#57)

Feat/integrate api topic page (#57) #79

Workflow file for this run

on:
release:
types: [created]
push:
branches:
- master
- main
tags:
- "v*"
- "rc-*"
- "dev-*"
- "test-*"
name: Release line-fact-check with Nix
jobs:
generate:
name: Build line-fact-check
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout for build
uses: actions/checkout@master
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Nix Flake outputs for release
run: |
nix build .#factcheck
zip -r line-fact-check-x86_64_linux.zip result/bin
nix build .#version
zip -r line-fact-check-x86_64_linux.zip result
- name: Build Docker images with Nix and load them into Docker daemon
run: |
echo "Building Docker images..."
nix build .#docker-factcheck && docker load < result
nix build .#docker-foo && docker load < result
- name: Push to GHCR
run: |
# Login to GitHub Container Registry
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# Get image IDs and tag them appropriately
FACTCHECK_IMAGE_ID=$(docker images --format "table {{.Repository}}:{{.Tag}}\t{{.ID}}" | grep factcheck | head -1 | awk '{print $2}')
FOO_IMAGE_ID=$(docker images --format "table {{.Repository}}:{{.Tag}}\t{{.ID}}" | grep foo | head -1 | awk '{print $2}')
# Determine tag based on ref type
if [[ "${{ github.ref_type }}" == "tag" ]]; then
TAG_NAME="${{ github.ref_name }}"
else
# For branches, get version from Nix flake output
unzip -p line-fact-check-x86_64_linux.zip result/version.txt > ./version.txt
FLAKE_VERSION=$(< ./version.txt)
TAG_NAME="${{ github.ref_name }}-${FLAKE_VERSION}-${{ github.sha }}"
fi
# Tag and push factcheck image
docker tag $FACTCHECK_IMAGE_ID ghcr.io/${{ github.repository }}/factcheck:$TAG_NAME
docker tag $FACTCHECK_IMAGE_ID ghcr.io/${{ github.repository }}/factcheck:latest
docker push ghcr.io/${{ github.repository }}/factcheck:$TAG_NAME
docker push ghcr.io/${{ github.repository }}/factcheck:latest
# Tag and push foo image
docker tag $FOO_IMAGE_ID ghcr.io/${{ github.repository }}/foo:$TAG_NAME
docker tag $FOO_IMAGE_ID ghcr.io/${{ github.repository }}/foo:latest
docker push ghcr.io/${{ github.repository }}/foo:$TAG_NAME
docker push ghcr.io/${{ github.repository }}/foo:latest
echo "Published images:"
echo "- ghcr.io/${{ github.repository }}/factcheck:$TAG_NAME"
echo "- ghcr.io/${{ github.repository }}/factcheck:latest"
echo "- ghcr.io/${{ github.repository }}/foo:$TAG_NAME"
echo "- ghcr.io/${{ github.repository }}/foo:latest"
- name: Upload artifact
uses: actions/upload-artifact@master
with:
name: line-fact-check-zip
path: ./line-fact-check-x86_64_linux.zip
release-tag:
if: ${{ github.ref_type == 'tag' }}
name: Release from tag
runs-on: ubuntu-latest
needs: generate
steps:
- name: Checkout for release
uses: actions/checkout@master
- name: Download pre-built zip artifact
uses: actions/download-artifact@v4
with:
name: line-fact-check-zip
path: ./
- name: Inspect version from Nix flake output [optional]
run: |
# Store 2025-07-10-1752226427 in env $RELEASE_DATE
unzip -l line-fact-check-x86_64_linux.zip
unzip -p line-fact-check-x86_64_linux.zip result/version.txt > ./version.txt
export FLAKE_VERSION=$(< ./version.txt)
echo "Release Flake version is: $FLAKE_VERSION"
- name: Create Release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
body: |
## Docker Images
This release includes Docker images published to GitHub Container Registry:
- `ghcr.io/${{ github.repository }}/factcheck:${{ github.ref_name }}`
- `ghcr.io/${{ github.repository }}/foo:${{ github.ref_name }}`
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./line-fact-check-x86_64_linux.zip
asset_name: line-fact-check-x86_64_linux.zip
asset_content_type: application/zip
release-branch:
if: ${{ github.ref_type == 'branch' }}
name: Release from branch
needs: generate
runs-on: ubuntu-latest
steps:
- name: Checkout for release
uses: actions/checkout@master
- name: Download pre-built zip artifact
uses: actions/download-artifact@v4
with:
name: line-fact-check-zip
path: ./
- name: Get version from Nix flake output
run: |
# Store 2025-07-10-1752226427 in env $RELEASE_DATE
unzip -p line-fact-check-x86_64_linux.zip result/version.txt > ./version.txt
export FLAKE_VERSION=$(< ./version.txt)
echo "Release Flake version is: $FLAKE_VERSION"
echo "RELEASE_DATE=$FLAKE_VERSION" >> $GITHUB_ENV
- name: Create Release for branch ${{ github.ref_name }}
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}-${{ env.RELEASE_DATE }}-${{ github.sha }}
release_name: Release ${{ github.ref_name }} ${{ env.RELEASE_DATE }} ${{ github.sha }}
draft: false
prerelease: false
body: |
## Docker Images
This release includes Docker images published to GitHub Container Registry:
- `ghcr.io/${{ github.repository }}/factcheck:${{ github.ref_name }}-${{ env.RELEASE_DATE }}-${{ github.sha }}`
- `ghcr.io/${{ github.repository }}/foo:${{ github.ref_name }}-${{ env.RELEASE_DATE }}-${{ github.sha }}`
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./line-fact-check-x86_64_linux.zip
asset_name: line-fact-check-x86_64_linux.zip
asset_content_type: application/zip