Skip to content

Commit

Permalink
Merge branch 'develop' into feature/GH-140-docker-image-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentganne committed Aug 12, 2021
2 parents 913a1ce + 060232c commit 41c549f
Show file tree
Hide file tree
Showing 16 changed files with 257 additions and 151 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Forge GH Actions Build"

on: [push, pull_request]


defaults:
run:
shell: bash

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup jfrog CLI
uses: jfrog/setup-jfrog-cli@v1
env:
JF_ARTIFACTORY_1: ${{ secrets.JF_ARTIFACTORY_SERVER_1 }}

- name: Ping Artifactory with jfrog CLI
run: |
# Ping the server
jfrog rt ping
- name: Generate artifacts
run: |
./build/zip_csar.sh
- name: Deploy artifacts to Artifactory
run: |
./build/deploy_artifactory.sh
39 changes: 39 additions & 0 deletions .github/workflows/cleanup_artifactory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Artifactory Cleanup
on:
workflow_dispatch:
inputs:
from_date:
description: ''
required: false
default: '30 days ago'
schedule:
- cron: '0 12 7,14,21,28 * *'

defaults:
run:
shell: bash

jobs:
cleanup:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup jfrog CLI
uses: jfrog/setup-jfrog-cli@v1
env:
JF_ARTIFACTORY_1: ${{ secrets.JF_ARTIFACTORY_SERVER_1 }}

- name: Ping Artifactory with jfrog CLI
run: |
# Ping the server
jfrog rt ping
- name: Run Cleanup
run: |
./build/gh-action-cleanup-artifactory.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FROM_DATE: ${{ github.event.inputs.from_date || '30 days ago' }}
90 changes: 90 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release
on:
workflow_dispatch:
inputs:
release_version:
description: 'version to be released'
required: true
default: ''


defaults:
run:
shell: bash

jobs:
release:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Configure Git user
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: pip install semantic_version

- name: Tag and push a release
id: release
run: |
./build/release.sh -v "${{ github.event.inputs.release_version }}"
read -r major minor patch prerelease build <<< $(python -c "import semantic_version; v = semantic_version.Version('${{ github.event.inputs.release_version }}'); print(v.major, v.minor, v.patch, '.'.join(v.prerelease), '.'.join(v.build));")
if [[ -z "${prerelease}" ]] ; then
echo "PRERELEASE=false" >> $GITHUB_ENV
else
echo "PRERELEASE=true" >> $GITHUB_ENV
fi
tagName="v${{ github.event.inputs.release_version }}"
echo "TAG_NAME=${tagName}" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout tag
uses: actions/checkout@v2
with:
ref: ${{ env.TAG_NAME }}

- name: Generate artifacts and changelog
run: |
./build/zip_csar.sh
awk '{f=1} f{ if (/^## / && i++>=1) exit; else print $0}' CHANGELOG.md | tee CHANGELOG-for-version.md
- name: Create or Update Github Release draft
id: update_release
uses: loicalbertin/action-gh-release@080e2e752ac77817dcfd2e8809873bdc24817584
with:
tag_name: ${{ env.TAG_NAME }}
body_path: CHANGELOG-for-version.md
name: ${{ env.TAG_NAME }}
prerelease: ${{ env.PRERELEASE }}
draft: true
files: build/csars/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Github Release
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.update_release.outputs.id }}
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## UNRELEASED

### BUG FIXES

* Docker installation requires apt-transport-https to work properly on Debian based systems ([GH-147](https://github.com/ystia/forge/issues/147))
* [Yorc] Error in AWS location configuration ([GH-145](https://github.com/ystia/forge/issues/145)) | Thanks to [@tibeer](https://github.com/tibeer) for this contribution

## 3.0.0-milestone.1 (April 25, 2021)

### DEPENDENCIES

* Ystia Forge components require now Alien4Cloud 3.0.0
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ystia Forge

[![Download](https://api.bintray.com/packages/ystia/forge/distributions/images/download.svg?version=2.2.0)](https://bintray.com/ystia/forge/distributions/2.2.0/link) [![Build Status](https://travis-ci.org/ystia/forge.svg?branch=develop)](https://travis-ci.org/ystia/forge) [![license](https://img.shields.io/github/license/ystia/forge.svg)](https://github.com/ystia/forge/blob/develop/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![Join the chat at https://gitter.im/ystia/forge](https://badges.gitter.im/ystia/forge.svg)](https://gitter.im/ystia/forge?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Download](https://img.shields.io/badge/download-v3.0.0--milestone.1-blue)](https://github.com/ystia/forge/releases/tag/v3.0.0-milestone.1) [![Build Status](https://github.com/ystia/forge/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/ystia/forge/actions) [![license](https://img.shields.io/github/license/ystia/forge.svg)](https://github.com/ystia/forge/blob/develop/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![Join the chat at https://gitter.im/ystia/forge](https://badges.gitter.im/ystia/forge.svg)](https://gitter.im/ystia/forge?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

A set of public TOSCA Types and Topology templates used by the Ystia project

Expand All @@ -10,6 +10,6 @@ See [our documentation for more details](https://github.com/ystia/forge/blob/dev

## Downloads

While Alien4Cloud has a support for importing types directly from Git, you can still visit our [BinTray account](https://bintray.com/ystia/forge/distributions) for downloading a release.
While Alien4Cloud has a support for importing types directly from Git, you can still visit our [GitHub releases page](https://github.com/ystia/forge/releases) for downloading a release.

Grab the [latest release here](https://bintray.com/ystia/forge/distributions/_latestVersion).
Grab the [latest release here](https://github.com/ystia/forge/releases/latest).
34 changes: 0 additions & 34 deletions build/bintray_release.json.tpl

This file was deleted.

34 changes: 14 additions & 20 deletions build/deploy_artifactory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
rootDir=$(readlink -f "${scriptDir}/..")

if [[ "${TRAVIS}" != "true" ]] ; then
if [[ "${GITHUB_ACTIONS}" != "true" ]] ; then
echo "This script is designed to publish CI build artifacts"
exit 0
fi
Expand All @@ -27,26 +27,20 @@ if [[ "${DISABLE_ARTIFACTORY}" == "true" ]] ; then
exit 0
fi

if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]] && [[ -z "${ARTIFACTORY_API_KEY}" ]] ; then
echo "Building an external pull request, artifactory publication is disabled"
exit 0
fi
ref="${GITHUB_REF#refs/*/}"

if [[ -n "${TRAVIS_TAG}" ]] ; then
deploy_path="forge-product-ystia-dist/ystia/forge/dist/${TRAVIS_TAG}/{1}"
elif [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]; then
deploy_path="forge-bin-dev-local/ystia/forge/dist/PR-${TRAVIS_PULL_REQUEST}/{1}"
if [[ "${GITHUB_REF}" == refs/tags/* ]] ; then
deploy_path="forge-product-ystia-dist/ystia/forge/dist/${ref}/{1}"
elif [[ "${GITHUB_REF}" == refs/pull/* ]] ; then
# For PRs ref is different
ref=$(echo "${GITHUB_REF}" | awk -F / '{print $3;}')
deploy_path="forge-bin-dev-local/ystia/forge/dist/PR-${ref}/{1}"
else
deploy_path="forge-bin-dev-local/ystia/forge/dist/${TRAVIS_BRANCH}/{1}"
deploy_path="forge-bin-dev-local/ystia/forge/dist/${ref}/{1}"
fi

curl -fL https://getcli.jfrog.io | sh

build_name="forge-travis-ci"

./jfrog rt c --interactive=false --apikey="${ARTIFACTORY_API_KEY}" --user=travis --url=https://ystia.jfrog.io/ystia ystia
./jfrog rt u --build-name="${build_name}" --build-number="${TRAVIS_BUILD_NUMBER}" --props="artifactory.licenses=Apache-2.0" --regexp "build/csars/(.*.zip)" "${deploy_path}"
# Do not publish environment variables as it may expose some secrets
#./jfrog rt bce "${build_name}" "${TRAVIS_BUILD_NUMBER}"
./jfrog rt bag "${build_name}" "${TRAVIS_BUILD_NUMBER}" "${rootDir}"
./jfrog rt bp "${build_name}" "${TRAVIS_BUILD_NUMBER}"
cd "${rootDir}"
jfrog rt u --props="artifactory.licenses=Apache-2.0" --regexp "build/csars/(.*.zip)" "${deploy_path}"
jfrog rt bce
jfrog rt bag
jfrog rt bp
39 changes: 39 additions & 0 deletions build/gh-action-cleanup-artifactory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

set -euo pipefail

comp_date=$(date --date="${FROM_DATE:=14 days ago}" +"%Y-%m-%dT%H:%M:%S.000Z")

local_dist_path="forge-bin-dev-local/ystia/forge/dist"

all_paths=$(jfrog rt s "${local_dist_path}/*/all-types*.zip" --limit 0 | jq -r ".[]| [.modified, .path] | @tsv" | sed -e "s@${local_dist_path}/\(.*\)/all-types-.*.zip@\1@g" | sort)

function get_pr_state() {
gh pr view "${1}" --json state | jq -r ".state"
}

function does_branch_exit() {
gh api --silent "/repos/:owner/:repo/branches/${1}" 2> /dev/null
return $?
}

function delete_artifactory_path() {
jfrog rt del --quiet "${local_dist_path}/${1}" || echo "failed to delete ${local_dist_path}/${1}"
}

echo "${all_paths}" | while read line ; do
item_date=$(echo "$line" | awk '{print $1}')
if [[ "${item_date}" > "${comp_date}" ]] ; then
continue
fi
ref=$(echo "${line}" | awk -F '\t' '{print $2}')
if [[ "${ref}" == PR-* ]] ; then
if [[ "$(get_pr_state "${ref##*PR-}")" != "OPEN" ]] ; then
delete_artifactory_path "${ref}"
fi
else
if ! does_branch_exit "${ref}" ; then
delete_artifactory_path "${ref}"
fi
fi
done
33 changes: 0 additions & 33 deletions build/pre_bintray_release.sh

This file was deleted.

Loading

0 comments on commit 41c549f

Please sign in to comment.