Skip to content

Commit

Permalink
Workflow Updates (#134)
Browse files Browse the repository at this point in the history
* Update action versions

* Formatting

* Cache dependencies

* Rename

* Add release instructions

* Require passing tests before release

* Create release from tag

* Tweak instructions
  • Loading branch information
mgacy authored Jan 3, 2024
1 parent 3d4a9e7 commit 8a85744
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tag Release
name: Create Release
on:
pull_request:
types:
Expand All @@ -7,12 +7,19 @@ on:
- 'main'

jobs:
tag:
test:
name: Test
if: github.event.pull_request.merged == true && github.head_ref == 'release'
uses: lytics/ios-sdk/.github/workflows/tests.yml@main

release:
name: Release
needs: test
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && github.head_ref == 'release'
steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get version
id: get-version
Expand All @@ -29,7 +36,7 @@ jobs:
private_key: ${{ secrets.FRONTEND_PROJECT_BOT_TOKEN }}

- name: Push tag
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
Expand All @@ -39,3 +46,16 @@ jobs:
ref: 'refs/tags/${{ env.current-version }}',
sha: '${{ github.sha }}'
})
- name: Create release
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: '${{ env.current-version }}',
draft: false,
prerelease: false
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: Prepare Release
on:
workflow_dispatch:
inputs:
Expand All @@ -10,13 +10,13 @@ on:
- patch
- minor
- major

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Bump Version file
id: bump
Expand All @@ -33,7 +33,7 @@ jobs:
with:
app_id: ${{ vars.FRONTEND_PROJECT_BOT_APP_ID }}
private_key: ${{ secrets.FRONTEND_PROJECT_BOT_TOKEN }}

- name: Create pull request
id: cpr
uses: peter-evans/create-pull-request@v4
Expand All @@ -46,8 +46,5 @@ jobs:
title: '[CI] Bump Version (${{ steps.bump.outputs.version }})'
body: |
Update `Version.swift` with bumped version number
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
draft: false
token: ${{ steps.generate-token.outputs.token }}
14 changes: 13 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Tests

on:
workflow_call:
workflow_dispatch:
push:
branches: [ main ]
Expand All @@ -17,16 +18,27 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v3
with:
path: .build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Build and test
uses: mxcl/xcodebuild@v1
with:
xcode: ^14
platform: iOS
code-coverage: true

- name: Convert coverage
uses: sersoft-gmbh/swift-coverage-action@v3
id: coverage-files

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Release Instructions

This package uses the [swift-version-file-plugin](https://github.com/Mobelux/swift-version-file-plugin) Swift Package Manager command plugin to maintain a source file--[`Sources/Lytics/Version.swift`](Sources/Lytics/Version.swift)--enabling the SDK to report its version to the Lytics API. To ensure that this is properly maintained, releases should only be created using the [`Prepare Release`](https://github.com/lytics/ios-sdk/actions/workflows/prepare-release.yml) workflow. Run it using `workflow_dispatch` event trigger from the `main` branch with the appropriate release type to create a new PR on a `release` branch containing an update to the Version file. Add any additional changes related to the release, like updating a changelog, to this PR. Finally, merge the `release` branch into `main` to delete it and trigger the [`Create Release`](.github/workflows/create-release.yml) workflow. This will create a new tag corresponding to the value of the updated Version file and a new release.

0 comments on commit 8a85744

Please sign in to comment.