Skip to content

Commit

Permalink
SDK-11 Test against a temp branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfann committed Sep 18, 2024
1 parent e056c48 commit 1ff6009
Showing 1 changed file with 51 additions and 33 deletions.
84 changes: 51 additions & 33 deletions .github/workflows/update-spm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,75 @@ on:
version:
description: 'Version number'
required: true
pull_request:
types: [opened, synchronize]
branches:
- main

permissions:
id-token: write
contents: read
contents: write

jobs:
update-sdk:
runs-on: macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Ensure version input is provided
run: |
if [ -z "${{ github.event.inputs.version }}" ]; then
echo "Error: Version number is required."
exit 1
fi
# - name: Ensure version input is provided
# run: |
# if [ -z "${{ github.event.inputs.version }}" ]; then
# echo "Error: Version number is required."
# exit 1
# fi

- name: Check if version already exists
run: |
VERSION=${{ github.event.inputs.version }}
if [ -d "OsanoConsentManagerSDK/${VERSION}" ]; then
echo "Version ${VERSION} already exists. Exiting."
exit 1
fi
working-directory: ${{ github.workspace }}
# - name: Check if version already exists
# run: |
# # VERSION=${{ github.event.inputs.version }}
# # VERSION=${{ github.event.inputs.version }}
# if [ -d "OsanoConsentManagerSDK/${VERSION}" ]; then
# echo "Version ${VERSION} already exists. Exiting."
# exit 1
# fi
# working-directory: ${{ github.workspace }}

- name: Download SDK zip
run: |
VERSION=${{ github.event.inputs.version }}
# VERSION=${{ github.event.inputs.version }}
VERSION="3.3.2"
URL="https://libraries.osano.com/ios/OsanoConsentManagerSDK/OsanoConsentManagerSDK-${VERSION}.zip"
if ! curl --output /dev/null --silent --head --fail "$URL"; then
echo "Error: SDK zip for version ${VERSION} does not exist at ${URL}. Exiting."
exit 1
fi
curl -L $URL -o OsanoConsentManagerSDK-${VERSION}.zip
working-directory: ${{ github.workspace }}


- name: Compute checksum
run: |
# VERSION=${{ github.event.inputs.version }}
VERSION="3.3.2"
CHECKSUM=$(swift package compute-checksum OsanoConsentManagerSDK-${VERSION}.zip)
echo "CHECKSUM=$CHECKSUM" >> $GITHUB_ENV
rm OsanoConsentManagerSDK-${VERSION}.zip
working-directory: ${{ github.workspace }}


- name: Create new version folder
run: |
VERSION=${{ github.event.inputs.version }}
mkdir -p OsanoConsentManagerSDK/${VERSION}
# VERSION=${{ github.event.inputs.version }}
VERSION="3.3.2"
mkdir -p OsanoConsentManagerSDK/${VERSION}-test
working-directory: ${{ github.workspace }}

- name: Copy template.podspec and update attributes
run: |
cp template.podspec OsanoConsentManagerSDK/${VERSION}/OsanoConsentManagerSDK.podspec
VERSION=${{ github.event.inputs.version }}
# VERSION=${{ github.event.inputs.version }}
VERSION="3.3.2"
cp template.podspec OsanoConsentManagerSDK/${VERSION}-test/OsanoConsentManagerSDK.podspec
URL="https://libraries.osano.com/ios/OsanoConsentManagerSDK/OsanoConsentManagerSDK-${VERSION}.zip"
sed -i '' "s|s.version = '<version>'|s.version = '${VERSION}'|" OsanoConsentManagerSDK/${VERSION}/OsanoConsentManagerSDK.podspec
sed -i '' "s|s.source = { :http => '<path-to-s3-zip>' }|s.source = { :http => '${URL}' }|" OsanoConsentManagerSDK/${VERSION}/OsanoConsentManagerSDK.podspec
Expand All @@ -74,25 +88,29 @@ jobs:
sed -i '' "s|checksum: .*|checksum: \"${CHECKSUM}\"|" Package.swift
working-directory: ${{ github.workspace }}

- name: Install GitHub CLI
run: |
brew install gh
# - name: Install GitHub CLI
# run: |
# brew install gh

- name: Create branch and commit changes
run: |
VERSION=${{ github.event.inputs.version }}
BRANCH_NAME="update-osano-sdk-${VERSION}"
# VERSION=${{ github.event.inputs.version }}
VERSION="3.3.2"
BRANCH_NAME="update-osano-sdk-${VERSION}-test"
git config --global user.name 'Osano Automation'
git config --global user.email '[email protected]'
git checkout -b $BRANCH_NAME
git add .
git commit -m "Update OsanoConsentManagerSDK to version $VERSION"
git push origin $BRANCH_NAME
- name: Create Pull Request
run: |
VERSION=${{ github.event.inputs.version }}
BRANCH_NAME="update-osano-sdk-${VERSION}"
gh pr create --title "Update OsanoConsentManagerSDK to version $VERSION" --body "This PR updates the OsanoConsentManagerSDK to version $VERSION." --head $BRANCH_NAME --base main
env:
GITHUB_TOKEN: ${{ secrets.OSANO_GITHUB_ACCESS_TOKEN }}
# - name: Create and push a new git tag
# run: |
# VERSION=${{ github.event.inputs.version }}
# git config --global user.email "Osano Automation"
# git config --global user.name "[email protected]"
# git tag -a "${VERSION}" -m "Release version ${VERSION}"
# git push origin "v${VERSION}"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# working-directory: ${{ github.workspace }}

0 comments on commit 1ff6009

Please sign in to comment.