Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ahramy committed Jan 31, 2025
1 parent 30dfc37 commit 49c07dd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# takes the latest commit hash on main and uploads the artefacts to CF storage
name: Release
name: Pre-release
on:
workflow_dispatch:

Expand All @@ -13,31 +13,48 @@ jobs:
releases: ${{ steps.prepare-matrix.outputs.releases }}

steps:
- name: Prepare JSON output to be a matrix GHA format
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y jq

- name: Get latest commit hash
id: get-commit-hash
run: echo "commit_hash=$(git rev-parse HEAD)" >> "$GITHUB_ENV"

- name: Prepare JSON output for matrix
id: prepare-matrix
run: |
# -J for json, -d for directories, -L 1 for depth of 1
export NAMES=$(tree -J -d -L 1 contracts | jq -c '.[0].contents | map(.name)')
echo "releases=$NAMES" >> $GITHUB_OUTPUT
# Extract package names from the 'contracts' directory and format properly
RELEASES_JSON=$(find contracts -maxdepth 1 -mindepth 1 -type d | sed 's|contracts/||' | jq -R . | jq -s --arg commit "${{ env.commit_hash }}" 'map({package_name: ., version: $commit, tag: .})')
# Debugging output
echo "Generated releases JSON: $RELEASES_JSON"
# Properly set output with correct JSON format
echo "releases=$(echo "$RELEASES_JSON" | jq -c)" >> "$GITHUB_OUTPUT"
# Publishes a release in case the release isn't published
build-and-upload:
name: Publish releases

runs-on: blacksmith-2vcpu-ubuntu-2204
name: Build artifacts for ${{ matrix.releases.package_name }}-${{ matrix.releases.version }}
needs: define-matrix

# Once a release is done for a package, we iterate on each of these packages and build its corresponding artifacts and upload them
strategy:
matrix:
releases: ${{ fromJson(needs.define-matrix.outputs.releases) }}

uses: ./.github/workflows/reusable-build-upload.yaml

permissions:
id-token: write
contents: read

with:
package-name: "${{ matrix.releases.package_name }}"
package-version: "${{ github.sha }}"
package-version: "${{ matrix.releases.version }}"
package-git-tag: "${{ matrix.releases.tag }}"

# CF Bucket related variables
cf-bucket-name: "${{ vars.CF_BUCKET_NAME }}"
Expand All @@ -46,7 +63,7 @@ jobs:
cf-config-bucket-root-key: "${{ vars.CF_BUCKET_ROOT_KEY }}"

# we just want to upload to CF, do not run a github release
github-release: "false"
github-release: false

secrets:
github-token: "${{ secrets.PAT_TOKEN }}"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/reusable-build-upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ on:
github-release:
description: "Whether to upload the build as a github release"
required: false
default: "true"
default: true
type: boolean

secrets:
Expand Down Expand Up @@ -69,9 +69,9 @@ jobs:
toolchain: 1.81.0
targets: wasm32-unknown-unknown

- name: Build artifacts for ${{ inputs.package-name }}-v${{ inputs.package-version }}
- name: Build artifacts for ${{ inputs.package-name }}
run: |
echo "Building wasm for '${{ inputs.package-name }}-v${{ inputs.package-version }}'";
echo "Building wasm for '${{ inputs.package-name }}'";
cargo install --locked stellar-cli --version 22.2.0 --features opt
cargo wasm -p ${{ inputs.package-name }}
stellar contract build
Expand All @@ -81,7 +81,7 @@ jobs:
- name: Prepare cross-steps variables
run: |
export PACKAGE_NAME='${{ inputs.package-name }}'
export PACKAGE_VERSION='v${{ inputs.package-version }}'
export PACKAGE_VERSION=${{ inputs.github-release && format('v{0}', inputs.package-version) || inputs.package-version }}
export BASE_ARTIFACTS_DIR="./target/wasm32-unknown-unknown/release"
export ARTIFACT_NAME="axelar-cgp-stellar-wasm-${PACKAGE_NAME}-${PACKAGE_VERSION}"
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:
# https://github.com/orgs/community/discussions/26263#discussioncomment-3251069
- name: Update the GitHub Release
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
if: ${{ inputs.github-release == 'true' }}
if: inputs.github-release
with:
tag_name: ${{ inputs.package-git-tag }} # This uses the tag from the push
files: |
Expand Down

0 comments on commit 49c07dd

Please sign in to comment.