Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davi17g committed Aug 4, 2024
1 parent 971d533 commit b8d9057
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 204 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/image-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Build Release Docker Images
on:
create:
tags: '*'

workflow_dispatch:
jobs:
build-images:
runs-on: ubuntu-latest
steps:
- name: Checkout Automation Code
uses: actions/checkout@v4
- name: Get Metadata
run: |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
echo "ISO8601=$(date "+%Y-%m-%dT%H:%M:%S%z")" >> $GITHUB_ENV
- name: Check Metadata
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
GIT_COMMIT_SHA: ${{ github.sha }}
GIT_BRANCH: main
LATEST: true
TAG: ${{ github.ref_name }}
CONTEXT: ${{ github.workspace }}
PROJECT: ${{ github.event.repository.name }}
run: |
echo "VERSION: $VERSION"
echo "ISO8601: $ISO8601"
echo "GIT_COMMIT_SHA: $GIT_COMMIT_SHA"
echo "TAG: $TAG"
echo "CONTEXT: $CONTEXT"
echo "PROJECT: $PROJECT"
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Setup Jfrog
# uses: jfrog/setup-jfrog-cli@v3
# env:
# JF_URL: ${{ secrets.ARTIFACTORY_URL }}
# JF_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }}
# - name: Login to JFrog
# uses: docker/login-action@v2
# with:
# registry: aerospike.jfrog.io
# username: ${{ secrets.ARTIFACTORY_USER }}
# password: ${{ secrets.ARTIFACTORY_TOKEN }}
# - name: Build and Push
# uses: docker/bake-action@v4
# env:
# GITHUB_TOKEN: ${{ secrets.PAT }}
# GIT_COMMIT_SHA: ${{ github.sha }}
# GIT_BRANCH: main
# LATEST: true
# TAG: ${{ github.ref_name }}
# CONTEXT: ${{ github.workspace }}
# PROJECT: ${{ github.event.repository.name }}
# with:
# workdir: ${{ github.workspace }}
# files: docker-bake.hcl
# targets: default
# - name: Promote image with version tag
# env:
# ARTIFACTORY_CONTAINER_DEV: ${{ vars.ARTIFACTORY_CONTAINER_DEV }}
# ARTIFACTORY_CONTAINER_PROD: ${{ vars.ARTIFACTORY_CONTAINER_PROD }}
# run: |
# jfrog rt docker-promote aerospike-backup-service \
# "$ARTIFACTORY_CONTAINER_DEV" \
# "$ARTIFACTORY_CONTAINER_PROD" \
# --source-tag "${{ github.event.inputs.version }}" \
# --target-tag "${{ github.event.inputs.version }}" \
# --user "${{ secrets.ARTIFACTORY_USER }}" \
# --password "${{ secrets.ARTIFACTORY_TOKEN }}" \
# --url "${{ secrets.ARTIFACTORY_PROMOTE_URL }}" \
# --copy
# - name: Promote image with latest tag
# env:
# ARTIFACTORY_CONTAINER_DEV: ${{ vars.ARTIFACTORY_CONTAINER_DEV }}
# ARTIFACTORY_CONTAINER_PROD: ${{ vars.ARTIFACTORY_CONTAINER_PROD }}
# run: |
# jfrog rt docker-promote aerospike-backup-service \
# "$ARTIFACTORY_CONTAINER_DEV" \
# "$ARTIFACTORY_CONTAINER_PROD" \
# --source-tag "${{ github.event.inputs.version }}" \
# --target-tag "latest" \
# --user "${{ secrets.ARTIFACTORY_USER }}" \
# --password "${{ secrets.ARTIFACTORY_TOKEN }}" \
# --url "${{ secrets.ARTIFACTORY_PROMOTE_URL }}" \
# --copy
87 changes: 87 additions & 0 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Create a Release and Push Release assets
on:
create:
tags: '*'

workflow_dispatch:
jobs:
create-release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Check if release exists
id: check-release
uses: actions/github-script@v7
with:
script: |
try {
const response = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: "${{ github.ref_name }}"
});
if (response.status === 200) {
console.log(`Release with tag exists.`);
core.setOutput('release-exists', 'true');
}
} catch (error) {
if (error.status === 404) {
console.log(`Release with tag does not exist.`);
core.setOutput('release-exists', 'false');
} else {
throw error;
}
}
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/create-release@v1
if: ${{ steps.check-release.outputs.release-exists == 'false'}}
id: create-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
draft: true
prerelease: true
build-artifacts:
needs:
- create-release
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.5"
- name: Install Dependencies
run: |
go install "github.com/goreleaser/nfpm/v2/cmd/nfpm@latest"
- name: Build Packages
env:
PAT: ${{ secrets.PAT }}
run: |
git config --global url."https://${PAT}:[email protected]/".insteadOf "https://github.com/"
make packages
- name: Find files matching "*.rpm" "*.deb" and "*sha256"
run: |
ASSET_LIST=$(find . -type f \( -name "*.deb" -or -name "*.rpm" -or -name "*.sha256" \) | tr '\n' ',')
echo "ASSET_LIST=$ASSET_LIST" >> $GITHUB_ENV
- name: Upload Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
upload_url="$(echo "${{ needs.create-release.outputs.upload_url }}" | sed 's/\(assets\).*/\1/')"
IFS=',' read -r -a asset_array <<< "$ASSET_LIST"
for file in "${asset_array[@]}"; do
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: $(file -b --mime-type $file)" \
"$upload_url?name=$(basename $file)" \
--data-binary "@$file"
done
204 changes: 0 additions & 204 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit b8d9057

Please sign in to comment.