Skip to content

📦 Build tenv

📦 Build tenv #38

Workflow file for this run

---
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
name: Build tenv
on:
workflow_dispatch:
push:
branches: [main]
paths:
- ".github/workflows/build-tenv.yml"
pull_request:
branches: [main]
paths:
- ".github/workflows/build-tenv.yml"
# concurrency:
# group: ${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: true
# Variables available to all jobs defined in this file
env:
DOCKER_BUILDKIT: 1
REGISTRY: ${{ vars.REGISTRY }}
# Declare default permissions as read only.
permissions: read-all
jobs:
lookup:
runs-on: ubuntu-latest
name: Lookup current version
permissions:
packages: write
contents: read
strategy:
fail-fast: false
container:
image: ghcr.io/northwood-labs/package-builder/ubuntu-v22.04:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
outputs:
already_built: ${{ steps.check.outputs.already_built }}
steps:
- name: Git clone
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- name: Lookup latest version of package
id: lookup_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Lookup version"
download-asset latest-tag -r tofuutils/tenv
echo "package_version=$(download-asset latest-tag -r tofuutils/tenv -s)" >> $GITHUB_ENV
- name: Check to see if we've already built this version
id: check
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWSSSEKMSID: "${{ secrets.AWSSSEKMSID }}"
PACKAGE_BUCKET: ${{ vars.PACKAGE_BUCKET }}
run: |
echo "::add-mask::${AWSSSEKMSID}"
# We'll use amzn2-x86_64 as a proxy for all packages pushed to S3.
aws s3api head-object \
--bucket "${PACKAGE_BUCKET}" \
--key "rpm/amazonlinux/2/x86_64/tenv-${package_version}-1.x86_64.rpm" 2>&1 \
&& echo "::notice title=Package exists::We don't need to rebuild, so let's stop the build here." \
&& echo "already_built=true" >> $GITHUB_OUTPUT \
|| true
build:
if: needs.lookup.outputs.already_built != 'true'
needs: lookup
name: Build and cache
uses: northwood-labs/package-building/.github/workflows/build-and-cache.yml@main
secrets: inherit
with:
package-name: tenv
package-version: "${package_version}"
upload:
if: needs.lookup.outputs.already_built != 'true'
needs: build
name: Upload to S3
uses: northwood-labs/package-building/.github/workflows/upload-to-s3.yml@main
secrets: inherit
with:
package-name: tenv
package-version: "${package_version}"
metadata:
if: needs.lookup.outputs.already_built != 'true'
needs: upload
name: Generate metadata
uses: northwood-labs/package-building/.github/workflows/generate-rpm-meta.yml@main
secrets: inherit