"Integration Release" #121
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Project | |
on: | |
workflow_call: | |
secrets: | |
token: | |
required: true | |
pull_request: | |
branches: | |
- "master" | |
jobs: | |
createinfo: | |
name: Create Some Infomation PR | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: PR Github Control | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR_NUMBER: ${{ github.event.number }} | |
run: | | |
gh pr edit $PR_NUMBER --add-assignee "${{ github.repository_owner }}" | |
gh pr edit $PR_NUMBER --add-label "enhancement" | |
checklist: | |
name: Checklist Checker | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Pull Request Checklist Checker | |
uses: venkatsarvesh/pr-tasks-completed-action@v1.0.0 | |
with: | |
repo-token: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Response Status Checklist | |
if: failure() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COMMENT_BODY: "# Check List Not Yet Finish ✅! | |
See more at: ${{ github.event.pull_request.html_url }}/checks | |
" | |
PR_NUMBER: ${{ github.event.number }} | |
run: | | |
# --edit-last | |
gh pr comment $PR_NUMBER --body "$COMMENT_BODY" || gh pr comment $PR_NUMBER --body "$COMMENT_BODY" | |
checklint: | |
name: Check Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Check SwiftLint | |
uses: norio-nomura/action-swiftlint@3.2.1 | |
with: | |
args: --strict | |
build: | |
name: Setup Enviroment ${{ matrix.swift }} on ${{ matrix.os }} | |
needs: | |
- checklint | |
- checklist | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macos-14] | |
swift: ["5.9"] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Cache Swift dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .build | |
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} | |
restore-keys: | | |
${{ runner.os }}-spm- | |
- name: Set Swift Version | |
uses: swift-actions/setup-swift@v1 | |
with: | |
swift-version: ${{ matrix.swift }} | |
- name: Build | |
id: build | |
run: swift build | |
- name: Run tests | |
run: swift test --enable-code-coverage -v | |
- name: Setup Xcode | |
uses: maxim-lobanov/setup-xcode@v1.4.0 | |
with: | |
xcode-version: latest-stable | |
- name: Get TestResult | |
run: xcodebuild -scheme CalendarView -destination 'platform=iOS Simulator,name=iPhone 12' -resultBundlePath TestResults test | |
- uses: kishikawakatsumi/xcresulttool@v1 | |
if: success() || failure() | |
with: | |
path: TestResults.xcresult | |
show-passed-tests: false | |
show-code-coverage: false | |
upload-bundles: never | |
# - name: Gather code coverage | |
# run: xcrun llvm-cov export -format="lcov" .build/debug/CalendarViewPackageTests.xctest/Contents/MacOS/CalendarViewPackageTests -instr-profile .build/debug/codecov/default.profdata > coverage_report.lcov | |
# - name: Upload coverage to Codecov | |
# uses: codecov/codecov-action@v2 | |
# with: | |
# token: ${{ secrets.CODECOV_TOKEN }} | |
# fail_ci_if_error: fail | |
# files: ./coverage_report.lcov | |
# verbose: true | |
- name: Return Status Test Fail | |
if: failure() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COMMENT_BODY: "## 😭 Unit Test Was Failed! | |
See more at: ${{ github.event.pull_request.html_url }}/checks | |
" | |
PR_NUMBER: ${{ github.event.number }} | |
run: | | |
# --edit-last | |
gh pr comment $PR_NUMBER --body "$COMMENT_BODY" || gh pr comment $PR_NUMBER --body "$COMMENT_BODY" | |
- name: Return Status Test Success | |
if: success() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COMMENT_BODY: "## ✅ Unit Test Success! <3" | |
PR_NUMBER: ${{ github.event.number }} | |
run: | | |
# --edit-last | |
gh pr comment $PR_NUMBER --body "$COMMENT_BODY" || gh pr comment $PR_NUMBER --body "$COMMENT_BODY" | |
allowgithub: | |
name: PR Approve | |
needs: | |
- build | |
- createinfo | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Approved PR | |
if: success() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Approved PR | |
run: | | |
gh pr review ${{ github.event.number }} --approve | |
- name: Allow and Merge When Succes | |
if: success() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
REPO_OWNER: ${{ github.repository_owner }} | |
# Using CLI Merge Pull Request | |
run: | | |
# Check if the PR is create by owner this repo | |
if [[ "${{ github.event.pull_request.user.login }}" == "${REPO_OWNER}" ]]; then | |
# gh pr merge ${{ github.event.number }} --squash --auto | |
fi | |
createtaggithub: | |
name: Create Tag Release | |
needs: allowgithub | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: | |
- macos-14 | |
swift: | |
- "5.9" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Build executable for release | |
env: | |
PRODUCT_NAME: ${{ secrets.PRODUCT_NAME }} | |
run: swift build -c release --arch arm64 --arch x86_64 --product ${{ secrets.PRODUCT_NAME }} | |
- name: Create Tag And Zip File | |
if: success() && github.event.pull_request.user.login == github.repository_owner | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
latest_tag=$(git describe --tags --abbrev=0) | |
if [[ -z "$latest_tag" ]]; then | |
echo "No previous tags found, starting at 1.0.0" | |
latest_tag="v1.0.0" | |
fi | |
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV # Export tag as environment variable | |
- name: Generate new version | |
run: | | |
# Extract major, minor, and patch from latest tag (adjust regex if needed) | |
version_regex="^v([0-9]+)\.([0-9]+)\.([0-9]+)$" | |
if [[ $LATEST_TAG =~ $version_regex ]]; then | |
major=${BASH_REMATCH[1]} | |
minor=${BASH_REMATCH[2]} | |
patch=$(( ${BASH_REMATCH[3]} + 1 )) | |
else | |
echo "Failed to parse version from tag" | |
exit 1 | |
fi | |
new_version="v${major}.${minor}.${patch}" | |
echo "VERSION=$new_version" >> $GITHUB_ENV # Export version as environment variable | |
# Create a tarball of the built product | |
tar -czf v$VERSION.tar.gz -C .build/apple/Products/Release ${{secrets.PRODUCT_NAME}}.swiftmodule | |
# Create a new tag with the incremented version number | |
gh release create v$VERSION --title "Release v$incremented_version" --notes "Release v$incremented_version" --prerelease 'v${$VERSION}.tar.gz' |