Skip to content

Commit

Permalink
test ci changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nolancon committed May 24, 2024
1 parent 41e27cf commit 6edffa6
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 61 deletions.
58 changes: 0 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,61 +164,3 @@ jobs:
with:
flags: unittests
file: _output/tests/linux_amd64/coverage.txt

publish-artifacts:
runs-on: ubuntu-22.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

steps:
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.DOCKER_BUILDX_VERSION }}
install: true

- name: Login to Upbound
uses: docker/login-action@v3
if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != ''
with:
registry: xpkg.upbound.io
username: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }}
password: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }}

- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Fetch History
run: git fetch --prune --unshallow

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Vendor Dependencies
run: make vendor vendor.check

- name: Build Artifacts
run: make -j2 build.all
env:
# We're using docker buildx, which doesn't actually load the images it
# builds by default. Specifying --load does so.
BUILD_ARGS: "--load"

- name: Publish Artifacts to GitHub
uses: actions/upload-artifact@v4
with:
name: output
path: _output/**

- name: Publish Artifacts
if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != ''
run: make publish BRANCH_NAME=${GITHUB_REF##*/}
90 changes: 90 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Publish

on:
push:
branches:
- release-*
pull_request:
types: [closed]
branches:
- main
workflow_dispatch: {}

concurrency:
group: ci-${{ github.ref }}-1
cancel-in-progress: true

permissions:
contents: read

env:
# Common versions
GO_VERSION: '1.21'
DOCKER_BUILDX_VERSION: 'v0.9.1'

# Common users. We can't run a step 'if secrets.XXX != ""' but we can run a
# step 'if env.XXX' != ""', so we copy these to succinctly test whether
# credentials have been provided before trying to run steps that need them.
UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }}
jobs:

publish-artifacts:
if: >
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-')) ||
(github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'candidate-'))
runs-on: ubuntu-22.04

steps:
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.DOCKER_BUILDX_VERSION }}
install: true

- name: Login to Upbound
uses: docker/login-action@v3
if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != ''
with:
registry: xpkg.upbound.io
username: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }}
password: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }}

- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Fetch History
run: git fetch --prune --unshallow

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Vendor Dependencies
run: make vendor vendor.check

- name: Build Artifacts
run: make -j2 build.all
env:
# We're using docker buildx, which doesn't actually load the images it
# builds by default. Specifying --load does so.
BUILD_ARGS: "--load"

- name: Publish Artifacts to GitHub
uses: actions/upload-artifact@v4
with:
name: output
path: _output/**

- name: Publish Artifacts
if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != ''
run: make publish BRANCH_NAME=${GITHUB_REF##*/}
10 changes: 7 additions & 3 deletions .github/workflows/release-candidatec-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ permissions:
jobs:
create-rc-pr:
# We don't want to run this on main upon merging the PR we are creating.
if: "!startsWith(github.event.pull_request.head.ref, 'release-candidate-')"
if: "!startsWith(github.event.pull_request.head.ref, 'candidate-')"
if: >
github.event_name == 'push' &&
github.ref == 'refs/heads/main' &&
!contains(github.event.head_commit.message, 'Set release candidate version'))
runs-on: ubuntu-22.04
permissions:
contents: write
Expand All @@ -32,7 +36,7 @@ jobs:
make submodules
version=$(make common.buildvars | grep "^VERSION=" | cut -d '=' -f 2)
echo "VERSION=$version" >> $GITHUB_ENV
branch=release-candidate-$version
branch=candidate-$version
echo "BRANCH=$branch" >> $GITHUB_ENV
- name: Set git config
Expand All @@ -50,7 +54,7 @@ jobs:
- name: Commit
run: |
git add .
git commit -m "Set release candidate version [skip ci]: ${VERSION}"
git commit -m "Set release candidate version: ${VERSION}"
git push --set-upstream origin $BRANCH
- name: Create a PR
Expand Down

0 comments on commit 6edffa6

Please sign in to comment.