diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e388bc..d625573 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build-and-test: name: Build and Test @@ -15,6 +19,14 @@ jobs: with: fetch-depth: 0 + - name: Cache Swift packages + uses: actions/cache@v4 + with: + path: .build + key: spm-${{ runner.os }}-${{ hashFiles('Package.swift') }} + restore-keys: | + spm-${{ runner.os }}- + - name: Build run: swift build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 29d4912..14b5077 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,10 @@ name: Release on: workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: release: name: Build and Release @@ -15,6 +19,14 @@ jobs: with: fetch-depth: 0 + - name: Cache Swift packages + uses: actions/cache@v4 + with: + path: .build + key: spm-${{ runner.os }}-${{ hashFiles('Package.swift') }} + restore-keys: | + spm-${{ runner.os }}- + - name: Validate version id: version uses: ./.github/actions/validate-version @@ -24,10 +36,20 @@ jobs: - name: Build release binary run: swift build -c release + - name: Generate release notes + run: | + PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | head -n1) + if [ -z "$PREV_TAG" ]; then + git log --pretty=format:"- %s" HEAD > release-notes.txt + else + git log --pretty=format:"- %s" ${PREV_TAG}..HEAD > release-notes.txt + fi + - name: Create release uses: diogot/gh-actions-workflows/actions/create-release@main with: tag: v${{ steps.version.outputs.version }} title: v${{ steps.version.outputs.version }} + body-file: release-notes.txt files: .build/release/swift-outdated token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Plugins/BuildVersionPlugin/plugin.swift b/Plugins/BuildVersionPlugin/plugin.swift index c995912..2ad50ba 100644 --- a/Plugins/BuildVersionPlugin/plugin.swift +++ b/Plugins/BuildVersionPlugin/plugin.swift @@ -8,7 +8,7 @@ struct BuildVersionPlugin: BuildToolPlugin { let outputFile = context.pluginWorkDirectoryURL.appending(path: "GeneratedVersion.swift") return [ - .prebuildCommand( + .buildCommand( displayName: "Generate version from VERSION file", executable: URL(fileURLWithPath: "/bin/bash"), arguments: [ @@ -23,7 +23,8 @@ struct BuildVersionPlugin: BuildToolPlugin { EOF """ ], - outputFilesDirectory: context.pluginWorkDirectoryURL + inputFiles: [versionFile], + outputFiles: [outputFile] ) ] } diff --git a/VERSION b/VERSION index 7dea76e..6d7de6e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.1 +1.0.2