Skip to content

Commit

Permalink
chore: update script and fix all annotation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wswebcreation committed Jan 1, 2024
1 parent 9e1c06b commit 0bc2655
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 33 deletions.
42 changes: 42 additions & 0 deletions .github/scripts/create_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Variables passed as environment
TOKEN=$GITHUB_TOKEN
TAG_NAME=$TAG_NAME
RELEASE_NAME=$RELEASE_NAME
BODY=$BODY
DRAFT=$DRAFT
PRE_RELEASE=$PRE_RELEASE

# Repository info
REPO_OWNER=$(jq -r ".repository.owner.login" $GITHUB_EVENT_PATH)
REPO_NAME=$(jq -r ".repository.name" $GITHUB_EVENT_PATH)

# GitHub API URL for creating a release
API_URL="https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases"

# Data for the release
DATA=$(jq -n --arg tag_name "$TAG_NAME" \
--arg name "$RELEASE_NAME" \
--arg body "$BODY" \
--arg draft "$DRAFT" \
--arg prerelease "$PRE_RELEASE" \
'{tag_name: $tag_name, name: $name, body: $body, draft: $draft, prerelease: $prerelease}')

# Make a POST request to create the release
RESPONSE=$(curl -H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
--data "$DATA" \
$API_URL)

# Check if the release was successfully created
RELEASE_ID=$(echo $RESPONSE | jq -r ".id")

if [ "$RELEASE_ID" != "null" ]; then
echo "Release created successfully! ID: $RELEASE_ID"
else
echo "Failed to create release"
echo "Response:"
echo $RESPONSE
exit 1
fi
25 changes: 25 additions & 0 deletions .github/scripts/upload_artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Variables passed from the workflow
ASSET_URL=$1
NEW_VERSION=$2
GITHUB_TOKEN=$3

# Trim off the end of the URL
ASSET_URL="${ASSET_URL%\{*}"

echo "Uploading Android App..."
curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: $(file -b --mime-type ./android.wdio.native.app.$NEW_VERSION.apk)" \
--data-binary @./android.wdio.native.app.$NEW_VERSION.apk \
"$ASSET_URL?name=android.wdio.native.app.$NEW_VERSION.apk"

echo "Uploading iOS App..."
curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: $(file -b --mime-type ./ios.simulator.wdio.native.app.$NEW_VERSION.zip)" \
--data-binary @./ios.simulator.wdio.native.app.$NEW_VERSION.zip \
"$ASSET_URL?name=ios.simulator.wdio.native.app.$NEW_VERSION.zip"
51 changes: 18 additions & 33 deletions .github/workflows/publish.apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ jobs:
- name: 🔄 Increment Version and Build Number
id: set_new_version
run: |
NEW_VERSION=$(npm version ${{ github.event.inputs.releaseType }} --no-git-tag-version)
echo "New version: $NEW_VERSION"
echo "::set-output name=new_version::$NEW_VERSION"
echo "new_version=$(npm version ${{ github.event.inputs.releaseType }} --no-git-tag-version)" >> $GITHUB_ENV
echo "New version: $new_version"
npm run build.versions
- name: 🌿 Create Pre-Release Branch
Expand All @@ -59,14 +58,14 @@ jobs:
ref: pre-release

- name: 🧳 Cache Gradle Wrapper
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}

- name: 🧳 Cache Gradle Dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
Expand Down Expand Up @@ -111,7 +110,7 @@ jobs:
ref: pre-release

- name: 🧳 Cache Cocoapods Pods
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}-20231231
Expand Down Expand Up @@ -198,7 +197,7 @@ jobs:
run: |
echo "Printing diffs between main and pre-release..."
git diff main pre-release
echo "diffs_printed=true" >> $GITHUB_ENV
echo "DIFFS_PRINTED=true" >> $GITHUB_ENV
- name: 🔥 Delete Pre-Release Branch
run: |
Expand All @@ -208,15 +207,16 @@ jobs:

- name: 🚀 Create GitHub Release
id: create_release
if: env.diffs_printed != 'true'
uses: actions/create-release@v1
if: env.DIFFS_PRINTED != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.prepare_release.outputs.new_version }}
release_name: Release ${{ needs.prepare_release.outputs.new_version }}
draft: true
prerelease: false
TAG_NAME: ${{ needs.prepare_release.outputs.new_version }}
RELEASE_NAME: Release ${{ needs.prepare_release.outputs.new_version }}
DRAFT: true
PRE_RELEASE: false
run: |
chmod +x .github/scripts/create_release.sh
.github/scripts/create_release.sh
- name: 📥 Download Android App Artifact
uses: actions/download-artifact@v3
Expand All @@ -229,27 +229,12 @@ jobs:
name: ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip

- name: 📤 Upload Artifacts to Release
if: env.diffs_printed != 'true'
run: |
ASSET_URL="${{ steps.create_release.outputs.upload_url }}"
ASSET_URL="${ASSET_URL%\{*}"
echo "Uploading Android App..."
curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: $(file -b --mime-type ./android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk)" \
--data-binary @./android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk \
"$ASSET_URL?name=android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk"
echo "Uploading iOS App..."
curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: $(file -b --mime-type ./ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip)" \
--data-binary @./ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip \
"$ASSET_URL?name=ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip"
if: env.DIFFS_PRINTED != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x .github/scripts/upload_artifacts.sh "${{ steps.create_release.outputs.upload_url }}" ${{ needs.prepare_release.outputs.new_version }} ${{ secrets.GITHUB_TOKEN }}
.github/scripts/upload_artifacts.sh
cleanup:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 0bc2655

Please sign in to comment.