Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: [BIPS-23045] Release & Promotion workflow refactored #178

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/promotion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build promotion

on:
workflow_dispatch:

jobs:
promotion:
runs-on: ubuntu-latest
steps:
- name: Jfrog setup
uses: jfrog/setup-jfrog-cli@96153976e4e81b3701e9cc0a5b9597e80614af81 # v4.5.1
env:
JF_ENV_1: ${{ secrets.ARTIFACTORY_DEPLOYER }}

- name: Extract version
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: version
with:
script: |
const version = context.ref.match(/[\d][\d*\.]*$/)[0];
core.setOutput("version", version);

- name: Promote artifact
run: |
VERSION="${{ steps.version.outputs.version }}"
BUILD_NAME="${{ github.event.repository.name }}"

BUILD_NUMBER="$(jfrog rt curl api/build/${BUILD_NAME} -s | jq -e -r '[.buildsNumbers[] | select(.uri | contains("'$VERSION'"))] | sort_by(.started) | reverse | .[0].uri[1:]')"

if [ -z "$BUILD_NUMBER" ]; then
echo "::error::Error retrieving build from Artifactory. No matching name/version. Name: $BUILD_NAME; Version: $VERSION"
exit 1
fi

echo "Promoting generic"
jfrog rt build-promote "$BUILD_NAME" "$BUILD_NUMBER" eng-generic-prod-local --status released --copy=true


43 changes: 39 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Release

env:
JFROG_CLI_BUILD_NAME: ${{ github.repository }}
JFROG_CLI_BUILD_NAME: ${{ github.event.repository.name }}
JFROG_SERVER: eng-generic-dev-local
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}

Expand All @@ -19,12 +19,43 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
outputs:
full_version: ${{ steps.version.outputs.full_version }}
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0

- name: Get next version increment
id: increment
run: |
shopt -s nocasematch
commit_message=$(git log --format=%B -n 1)
if [[ $commit_message == "feat!:"* ]]; then
echo "INCREMENT=major" >> "$GITHUB_OUTPUT"
elif [[ $commit_message == "feat:"* ]]; then
echo "INCREMENT=minor" >> "$GITHUB_OUTPUT"
elif [[ $commit_message == "fix:"* ]]; then
echo "INCREMENT=patch" >> "$GITHUB_OUTPUT"
fi

- name: Get next version numbers
uses: reecetech/[email protected]
id: version_number
with:
increment: ${{ steps.increment.outputs.increment }}

- name: Get full version name and version numbers
id: version
run: |
if [[ "${{ github.actor }}" == "beyondtrust-release-app" ]]; then
echo "full_version="$(git tag --sort "-committerdate" | cut -d$'\n' -f1)"" >> "$GITHUB_OUTPUT"
else
version=$(echo ${{ steps.version_number.outputs.version }} | sed -e 's/-pre.*//g')
echo "full_version="${version}.${{ github.run_number }}"" >> "$GITHUB_OUTPUT"
fi

- name: Build library
run: |
go build
Expand Down Expand Up @@ -112,19 +143,23 @@ jobs:
env:
JF_ENV_1: ${{ secrets.ARTIFACTORY_DEPLOYER }}

- name: Configure JFrog CLI build number
run: |
echo "JFROG_CLI_BUILD_NUMBER=${{ needs.build.outputs.full_version }}" >> $GITHUB_ENV

- name: Setting up artifactory
run: |
mkdir go-library-passwordsafe
mkdir -p go-library-passwordsafe/${{ needs.build.outputs.full_version }}

- name: Download library binary
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: library
path: go-library-passwordsafe
path: go-library-passwordsafe/${{ needs.build.outputs.full_version }}

- name: Send artifacts to Jfrog
run: |
jfrog rt u "go-library-passwordsafe/*" ${{ env.JFROG_SERVER }}
jfrog rt u "go-library-passwordsafe/${{ needs.build.outputs.full_version }}/*" ${{ env.JFROG_SERVER }}

- name: Publish Build Information
run: |
Expand Down
Loading