Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Test and Add Release Workflows #27

Merged
merged 4 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release
on:
workflow_dispatch:
inputs:
release_type:
description: Type of release
type: choice
required: true
options:
- patch
- minor
- major

jobs:
test:
name: Test
uses: Mobelux/ImageFetcher/.github/workflows/test.yml@main

release:
name: Release
runs-on: ubuntu-latest
needs: test
permissions:
contents: write
steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Get latest release version
id: get_current_version
uses: actions/github-script@v7
with:
script: |
const { data: { tag_name } } = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
})
return tag_name

- name: Bump version
id: bump
uses: Mobelux/bump-version-action@v1
with:
release-type: ${{ inputs.release_type }}
version: ${{ steps.get_current_version.outputs.result }}

- name: Push tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.bump.outputs.version }}',
sha: context.sha
})

- name: Create release
uses: actions/github-script@v7
with:
script: |
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: '${{ steps.bump.outputs.version }}',
generate_release_notes: true,
draft: false,
prerelease: false
})
19 changes: 0 additions & 19 deletions .github/workflows/swift.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test
on:
workflow_call:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:
unit_tests:
name: Test
runs-on: macos-latest

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

- name: Cache dependencies
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-

- name: Build
run: swift build

- name: Run tests
run: swift test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ xcuserdata/
.swiftpm/xcode/package.xcworkspace/xcuserdata
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
Package.resolved
/.vscode