From a4a4cad5f2365cf3d8e3832321a522ff254aa060 Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Wed, 1 Nov 2023 15:37:29 -0700 Subject: [PATCH 1/2] Use Go style pseudo-versions when there is no semver supplied The CI workflow uses a semver (e.g. v1.0.0) when you run it using the workflow_dispatch trigger and supply one explicitly. This is how you 'release' a function. Today when the workflow runs for a PR or regular main branch build we default to v0.0.0-. This is a very simple way to tag development builds with no user input required. It's handy that the resulting package can be correlated to the git commit that produced it using the git SHA. A major flaw of this implementation is that newer SHAs do not sort above older SHAs when treated as semantic versions. This commit switches us to a simple approximation of the Go pseudoversions you would see in a go.mod file, as described by https://go.dev/ref/mod#pseudo-versions. These versions include the git commit time before the SHA, so newer commits will be considered newer versions when processing the semver. We also switch to using the first 12 characters of the SHA. This reduces the risk of collision, and makes us match exactly Go's pseudoversion implementation. Signed-off-by: Nic Cope --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b18fbc8..569a583 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -152,10 +152,12 @@ jobs: password: ${{ secrets.XPKG_TOKEN }} # If a version wasn't explicitly passed as a workflow_dispatch input we - # default to version v0.0.0-shortsha, for example v0.0.0-8ed5691. + # default to version v0.0.0--, for example + # v0.0.0-20231101115142-1091066df799. This is a simple implementation of + # Go's pseudo-versions: https://go.dev/ref/mod#pseudo-versions. - name: Set Default Multi-Platform Package Version if: env.XPKG_VERSION == '' - run: echo "XPKG_VERSION=v0.0.0-$(git rev-parse --short HEAD)" >> $GITHUB_ENV + run: echo "XPKG_VERSION=v0.0.0-$(date -d@$(git show -s --format=%ct) +%Y%m%d%H%M%S)-$(git rev-parse --short=12 HEAD)" >> $GITHUB_ENV - name: Push Multi-Platform Package to Upbound if: env.XPKG_ACCESS_ID != '' From 7b817aa3c7f5b00966a77503d47b8b9d48a88a32 Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Tue, 2 Jan 2024 12:36:16 -0800 Subject: [PATCH 2/2] Use upload and download-artifact v4 This new version requires unique artifact names. We achieve this by omitting the downloaded artifact name, which causes the action to download all artifacts from the run. Signed-off-by: Nic Cope --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 569a583..0b5bced 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,9 +116,9 @@ jobs: run: ./crossplane xpkg build --package-file=${{ matrix.arch }}.xpkg --package-root=package/ --embed-runtime-image-tarball=runtime-${{ matrix.arch }}.tar - name: Upload Single-Platform Package - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: packages + name: package-${{ matrix.arch }} path: "*.xpkg" if-no-files-found: error retention-days: 1 @@ -135,10 +135,10 @@ jobs: uses: actions/checkout@v4 - name: Download Single-Platform Packages - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: packages path: . + merge-multiple: true - name: Setup the Crossplane CLI run: "curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh"