Skip to content

Commit

Permalink
add environment to publish on different environments while needed
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomontero committed May 28, 2024
1 parent 071cc94 commit df46588
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
35 changes: 34 additions & 1 deletion .github/workflows/reusable-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,48 @@ on:
description: 'The run id of the build job'
required: true
type: string
environment:
description: 'The environment to publish to'
required: true
type: string

jobs:
download-artifacts:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Download all artifacts
uses: dawidd6/[email protected]
with:
run_id: ${{ inputs.build_run_id }}
path: build/
- name: ls build
run: ls build
run: ls -la build
- name: compress build with gz
run: |
./compress-release.sh
- name: generate manifest
run: |
./generate-manifest.sh ./build ${{ secrets.BINARIES_BASE_URL }}
upload-binaries:
needs: download-artifacts
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
strategy:
matrix:
platform-arch:
- { platform: "darwin", arch: "x64" }
- { platform: "darwin", arch: "arm64" }
- { platform: "linux", arch: "x64" }
- { platform: "windows", arch: "x64" }
steps:
- name: Aws Assume Role
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: 'openocd-upload-session'
aws-region: ${{ secrets.AWS_S3_REGION }}
- name: Upload to darwin x64
run: |
aws s3 cp ./build/release/openocd-{platform}-${arch} s3://${{ secrets.BINARIES_BUCKET }}/openocd/${platform}/${arch} --recursive
1 change: 1 addition & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ jobs:
secrets: inherit
needs: call-build
with:
environment: staging
build_run_id: ${{ github.run_id }}
8 changes: 3 additions & 5 deletions generate-manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
version=$(cat version)
# Directory containing the files
dir_path=${1:-"./build"}
url_prefix=${2:-"https://binaries.particle.io/openocd"}

# Function to generate manifest.json content
generate_manifest() {
Expand All @@ -20,7 +21,7 @@ echo "platform: $platform"
"name": "${name}",
"version": "${version}",
"main": "./bin",
"url": "https://binaries.particle.io/openocd/${platform}/${arch}/${version}.tar.gz",
"url": "${url_prefix}/${platform}/${arch}/${version}.tar.gz",
"sha256": "${sha256}"
}
EOL
Expand All @@ -30,7 +31,6 @@ EOL
for file in "$dir_path"/*.tar.gz; do
filename=$(basename -- "$file")
# Extract platform and arch from the filename
echo "doing something"
platform=$(echo $filename | awk -F '-' '{print $2}')
arch=$(echo $filename | awk -F '-' '{print $3}')

Expand All @@ -44,11 +44,9 @@ for file in "$dir_path"/*.tar.gz; do

# Generate the new file name without the extension
new_file_name="${name}-${version}"
new_path="${name}-${platform}-${arch}"
new_path="release/${name}-${platform}-${arch}"
# Create a directory for the current file to store the manifest.json
echo "creating directory ${dir_path}/${new_path}"
echo ${new_file_name}
echo ${new_path}
mkdir -p "${dir_path}/${new_path}"


Expand Down

0 comments on commit df46588

Please sign in to comment.