Skip to content

Commit

Permalink
SWC-6663: build and publish SWC artifact from GH (#5513)
Browse files Browse the repository at this point in the history
* CI

* Fix cond

* Fix cond

* Fix

* Fix syntax

* Actual

* Invert logic to test

* Test

* Test

* Reset test

* Test

* Fix e2e

* Merge changes into existing infra

* Add release branch workflow

* Fixes from POC

* Pass creds

* Typo
  • Loading branch information
xschildw authored Sep 11, 2024
1 parent 50c77ea commit bc1c926
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
- uses: actions/checkout@v3
- name: Build SWC
uses: ./.github/workflows/build
with:
mvn_goal: package
- name: Upload build to GitHub Actions Artifacts
uses: actions/upload-artifact@v3
with:
Expand Down
20 changes: 19 additions & 1 deletion .github/workflows/build/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
name: 'Build SWC'
description: 'Build SWC'
inputs:
mvn_goal:
description: the goal that maven needs to run
required: true
pom_version:
description: the version for the generated artifact
required: false
default: ''
runs:
using: 'composite'
steps:
Expand All @@ -9,6 +17,16 @@ runs:
java-version: '11'
distribution: 'corretto'
cache: maven
server-id: sagebionetworks
server-username: ${{ env.MAVEN_USERNAME }}
server-password: ${{ env.MAVEN_USERPWD }}

- name: Version pom.xml
shell: bash
run: |
if [ "${{ inputs.pom_version }}" != "" ]; then
mvn versions:set -DnewVersion=${{ inputs.pom_version }}
fi
- name: Build with Maven
shell: bash
run: mvn -B package --file pom.xml
run: mvn -B ${{ inputs.mvn_goal }} --file pom.xml
41 changes: 41 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: build-main

on:
push:
branches: [develop, release-**]
pull_request:
branches: [develop, release-**]

jobs:
call-build:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0

- name: Set POM version for dev branch
if: ${{ github.ref == 'refs/heads/develop' }}
run: echo "pomversion=$(date +%Y-%m-%d)-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Set POM version for release branch
if: ${{ startsWith(github.ref, 'refs/heads/release-') }}
run: echo "pomversion=$(date +%Y-%m-%d)-$(git describe --tags)" >> $GITHUB_ENV

- uses: ./.github/workflows/build
with:
mvn_goal: package
pom_version: ${{ env.pomversion }}
env:
MAVEN_USERNAME: ${{ secrets.PLATFORM_ARTIFACTORY_USER }}
MAVEN_USERPWD: ${{ secrets.PLATFORM_ARTIFACTORY_PWD }}

call-test:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/build
with:
mvn_goal: test
19 changes: 0 additions & 19 deletions .github/workflows/maven.yml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: release

on:
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0

- id: extract_release
run: |
branch_name="${GITHUB_REF#refs/heads/}"
if [[ $branch_name =~ ^release-([0-9]+)$ ]]; then
release_number=${BASH_REMATCH[1]}
echo "release_number=$release_number" >> $GITHUB_ENV
else
echo "Invalid branch name format"
exit 1
fi
- id: git_config
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- id: push_prod_tag
run: |
tag_name="${release_number}.1"
git tag -a $tag_name -m stack-${release_number}-prod
git push origin $tag_name
- id: create_new_release_branch
run: |
git checkout develop
next_release_number=$((release_number + 1))
new_branch="release-${next_release_number}"
git checkout -b $new_branch
new_tag="${next_release_number}.0"
git tag -a $new_tag -m stack-${next_release_number}-staging
git push origin $new_branch
echo "pomversion=$new_tag" >> $GITHUB_ENV
- id: build_new_release_branch
uses: ./.github/workflows/build
with:
mvn_goal: package
pom_version: ${{ env.pomversion }}

0 comments on commit bc1c926

Please sign in to comment.