📦 Build tenv #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# 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}" | |
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 | |
- name: Build the package | |
if: steps.check.outputs.already_built != 'true' | |
working-directory: ./packages/tenv | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} | |
run: | | |
# We just need to set a git tag. None of the rest of this matters. | |
git init | |
git config user.email "[email protected]" | |
git config user.name "Your Name" | |
git add . | |
git commit -m "Test" | |
git remote add origin https://example.com | |
git tag "${package_version}" | |
# Build the package | |
goreleaser release --clean --nightly --skip=announce,publish,validate | |
- name: Cache the packages | |
uses: actions/cache/save@v4 | |
id: cache-packages | |
with: | |
key: "tenv-${package_version}" | |
path: packages/tenv/dist | |
upload: | |
if: needs.lookup.outputs.already_built != 'true' | |
needs: lookup | |
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 |