From 26b38597022d3342e752ccfc95ca9304e311bec7 Mon Sep 17 00:00:00 2001 From: UncleGedd <42304551+UncleGedd@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:51:36 -0500 Subject: [PATCH] chore: refactor nightly release process (#825) --- .github/workflows/nightly-release.yaml | 63 ++++++-------------------- .goreleaser-nightly.yaml | 59 ------------------------ hack/create-nightly-tag.sh | 62 ------------------------- tasks.yaml | 8 ++++ 4 files changed, 22 insertions(+), 170 deletions(-) delete mode 100644 .goreleaser-nightly.yaml delete mode 100755 hack/create-nightly-tag.sh diff --git a/.github/workflows/nightly-release.yaml b/.github/workflows/nightly-release.yaml index c5270337..27d21d94 100644 --- a/.github/workflows/nightly-release.yaml +++ b/.github/workflows/nightly-release.yaml @@ -13,31 +13,6 @@ jobs: packages: write uses: ./.github/workflows/release-tests.yaml - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - fetch-depth: 0 - - - name: Setup golang - uses: ./.github/actions/golang - - - name: Install UDS CLI - uses: ./.github/actions/install-uds-cli - - - name: Build CLI - run: | - uds run build-cli-linux-amd - - # Upload the contents of the build directory for later stages to use - - name: Upload build artifacts - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 - with: - name: build-artifacts - path: build/ - retention-days: 1 push: runs-on: ubuntu-latest environment: release-nightly @@ -48,36 +23,26 @@ jobs: - name: Checkout uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: - fetch-depth: 0 + fetch-tags: 'true' - name: Setup golang uses: ./.github/actions/golang - - name: Install tools - uses: ./.github/actions/install-tools - - - name: Download build artifacts - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 - with: - name: build-artifacts - path: build/ + - name: Install UDS CLI + uses: ./.github/actions/install-uds-cli - - name: Create tag + - name: Build binary artifacts run: | - ./hack/create-nightly-tag.sh - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN}} + uds run build-all - - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - fetch-depth: 0 - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0 - with: - distribution: goreleaser - version: latest - args: release --clean --verbose --config .goreleaser-nightly.yaml + - name: Update nightly-unstable tag env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} + run: | + # cleanup old release + gh release delete nightly-unstable --cleanup-tag -y || true + # generate new release + gh release create nightly-unstable './build/*' \ + -t "nightly-unstable" \ + --prerelease \ + -n 'Nightly unstable build' diff --git a/.goreleaser-nightly.yaml b/.goreleaser-nightly.yaml deleted file mode 100644 index 0ffcc2b3..00000000 --- a/.goreleaser-nightly.yaml +++ /dev/null @@ -1,59 +0,0 @@ -before: - hooks: - - go mod tidy - -# Build a universal macOS binary -universal_binaries: - - replace: false - -# Build the different combination of goos/arch binaries -builds: - - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - ldflags: - - -s -w -X 'github.com/defenseunicorns/uds-cli/src/config.CLIVersion={{.Tag}}' -X 'github.com/defenseunicorns/zarf/src/config.ActionsCommandZarfPrefix=zarf' - - -X 'github.com/defenseunicorns/zarf/src/config.ActionsCommandZarfPrefix=zarf' - - -X 'github.com/derailed/k9s/cmd.version=${K9S_VERSION}' - - -X 'github.com/google/go-containerregistry/cmd/crane/cmd.Version=${CRANE_VERSION}' - - -X 'github.com/defenseunicorns/zarf/src/cmd/tools.syftVersion=${SYFT_VERSION}' - - -X 'github.com/defenseunicorns/zarf/src/cmd/tools.archiverVersion=${ARCHIVER_VERSION}' - - -X 'github.com/defenseunicorns/zarf/src/cmd/tools.helmVersion=${HELM_VERSION}' - goarch: - - amd64 - - arm64 - binary: uds - -# Save the built artifacts as binaries (instead of wrapping them in a tarball) -archives: - - format: binary - name_template: "{{ .ProjectName }}_{{ .Tag }}_{{- title .Os }}_{{ .Arch }}" - -# generate a sha256 checksum of all release artifacts -checksum: - name_template: "checksums.txt" - algorithm: sha256 - -# generate sboms for each binary artifact -sboms: - - artifacts: binary - documents: - - "sbom_{{ .ProjectName }}_{{ .Tag }}_{{- title .Os }}_{{ .Arch }}.sbom" - -snapshot: - name_template: "{{ incpatch .Version }}-snapshot" - -# Use the auto-generated changelog github provides -changelog: - use: github-native - -# Generate a GitHub release and publish the release for the tag -release: - github: - owner: defenseunicorns - name: uds-cli - prerelease: true - mode: append - draft: false diff --git a/hack/create-nightly-tag.sh b/hack/create-nightly-tag.sh deleted file mode 100755 index 1d9e8291..00000000 --- a/hack/create-nightly-tag.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env sh - -# This script creates and/or updates a nightly tag for the uds-cli repo -# The nightly tag is created from the latest commit on the main branch - -tag="0.0.0-nightly" - -# get oid and repositoryId for GH API Graphql Mutation -oid=$(gh api graphql -f query=' - { - repository(owner: "defenseunicorns", name: "uds-cli") { - id - ref(qualifiedName: "refs/heads/main") { - target { - ... on Commit { - oid - } - } - } - } - }' | jq -r '.data.repository.ref.target.oid') - -repositoryId=$(gh api graphql -f query=' - { - repository(owner: "defenseunicorns", name: "uds-cli") { - id - } - }' | jq -r '.data.repository.id') - - -# get existing tag and save to existingRefId var -existingRefId=$(gh api graphql -f query=' - { - repository(owner: "defenseunicorns", name: "uds-cli") { - ref(qualifiedName: "refs/tags/'$tag'") { - id - } - } - }' | jq -r '.data.repository.ref.id') - -# remove any existing nightly tags -gh api graphql -f query=' -mutation DeleteRef { - deleteRef(input:{refId:"'$existingRefId'"}) { - clientMutationId - } -}' --silent && - -echo "Existing '$tag' tag removed successfully" - -# create a signed nightly tag -gh api graphql -f query=' -mutation CreateRef { - createRef(input:{name:"refs/tags/'$tag'",oid:"'$oid'",repositoryId:"'$repositoryId'"}) { - ref { - id - name - } - } -}' --silent && - -echo "New '$tag' tag created successfully" diff --git a/tasks.yaml b/tasks.yaml index 53fb5c0c..9304c123 100644 --- a/tasks.yaml +++ b/tasks.yaml @@ -53,6 +53,14 @@ tasks: setVariables: - name: BUILD_ARGS + - name: build-all + description: build all the CLI binaries + actions: + - task: build-cli-linux-amd + - task: build-cli-linux-arm + - task: build-cli-mac-intel + - task: build-cli-mac-apple + - name: build-cli-linux-amd description: build the CLI for Linux AMD64 actions: