Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ahoppen committed Oct 24, 2024
1 parent 3ca1a18 commit f87273d
Showing 1 changed file with 95 additions and 48 deletions.
143 changes: 95 additions & 48 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,45 @@ on:
required: true

jobs:
check_triggering_actor:
name: Check user is allowed to create release
# Only a single user should be allowed to create releases to avoid two people triggering the creation of a release
# at the same time. If the release manager changes between users, update this condition.
runs-on: ubuntu-latest
test:
name: Test
runs-on: windows-2022
needs: define_tags
steps:
- run: |
if [[ "${{ github.triggering_actor }}" != "ahoppen" ]]; then
echo "${{ github.triggering_actor }} is not allowed to create a release"
exit 1
fi
- name: Checkout repository
uses: actions/checkout@v4
- name: Test
run: |
mkdir $env:TEMP\run-script
echo @"
${{ needs.define_tags.outputs.release_commit_patch }}
"@ > $env:TEMP\patch.diff
git config --local user.name "swift-ci"
git config --local user.email "[email protected]"
echo @'
echo "------"
cat $env:TEMP\patch.diff | git am
'@ >> $env:TEMP\run-script\pre-build.ps1
pwsh.EXE $env:TEMP\run-script\pre-build.ps1
# check_triggering_actor:
# name: Check user is allowed to create release
# # Only a single user should be allowed to create releases to avoid two people triggering the creation of a release
# # at the same time. If the release manager changes between users, update this condition.
# runs-on: ubuntu-latest
# steps:
# - run: |
# if [[ "${{ github.triggering_actor }}" != "ahoppen" ]]; then
# echo "${{ github.triggering_actor }} is not allowed to create a release"
# exit 1
# fi
define_tags:
name: Determine dependent swift-syntax version and prerelease date
runs-on: ubuntu-latest
outputs:
swift_syntax_tag: ${{ steps.swift_syntax_tag.outputs.swift_syntax_tag }}
swift_format_version: ${{ steps.swift_format_version.outputs.swift_format_version }}
release_commit_patch: ${{ steps.create_release_commits.outputs.release_commit_patch }}
steps:
- name: Determine swift-syntax tag to depend on
id: swift_syntax_tag
Expand All @@ -65,45 +87,70 @@ jobs:
fi
echo "Using swift-format version: $SWIFT_FORMAT_VERSION"
echo "swift_format_version=$SWIFT_FORMAT_VERSION" >> "$GITHUB_OUTPUT"
test_debug:
name: Test in Debug configuration
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
needs: define_tags
with:
pre_build_command: bash .github/workflows/create-release-commits.sh '${{ needs.define_tags.outputs.swift_syntax_tag }}' '${{ needs.define_tags.outputs.swift_format_version }}'
# We require that releases of swift-format build without warnings
build_command: swift test -Xswiftc -warnings-as-errors
test_release:
name: Test in Release configuration
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
needs: define_tags
with:
pre_build_command: bash .github/workflows/create-release-commits.sh '${{ needs.define_tags.outputs.swift_syntax_tag }}' '${{ needs.define_tags.outputs.swift_format_version }}'
# We require that releases of swift-format build without warnings
build_command: swift test -c release -Xswiftc -warnings-as-errors
create_tag:
name: Create Tag
runs-on: ubuntu-latest
needs: [check_triggering_actor, test_debug, test_release, define_tags]
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create release commits
run: bash .github/workflows/create-release-commits.sh '${{ needs.define_tags.outputs.swift_syntax_tag }}' '${{ needs.define_tags.outputs.swift_format_version }}'
- name: Tag release
id: create_release_commits
run: |
git tag "${{ needs.define_tags.outputs.swift_format_version }}"
git push origin "${{ needs.define_tags.outputs.swift_format_version }}"
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
run: |
if [[ "${{ github.event.inputs.prerelease }}" != "true" ]]; then
# Only create a release automatically for prereleases. For real releases, release notes should be crafted by hand.
exit
fi
gh release create "${{ needs.define_tags.outputs.swift_format_version }}" \
--title "${{ needs.define_tags.outputs.swift_format_version }}" \
--prerelease
BASE_COMMIT=$(git rev-parse HEAD)
bash .github/workflows/create-release-commits.sh '${{ steps.swift_syntax_tag.outputs.swift_syntax_tag }}' '${{ steps.swift_format_version.outputs.swift_format_version }}'
{
echo 'release_commit_patch<<EOF'
git format-patch "$BASE_COMMIT"..HEAD --stdout
echo EOF
} >> "$GITHUB_OUTPUT"
# test_debug:
# name: Test in Debug configuration
# uses: ahoppen/github-workflows/.github/workflows/swift_package_test.yml@windows-pre-build
# needs: define_tags
# with:
# linux_pre_build_command: |
# git config --global --add safe.directory "$(realpath .)"
# git config --local user.name 'swift-ci'
# git config --local user.email '[email protected]'
# echo '${{ needs.define_tags.outputs.release_commit_patch }}' | git am
# # We require that releases of swift-format build without warnings
# linux_build_command: swift test -Xswiftc -warnings-as-errors
# windows_pre_build_command: |
# git config user.name "swift-ci"
# git config user.email "[email protected]"
# git config --global user.name "swift-ci"
# git config --global user.email "[email protected]"
# echo @"
# ${{ needs.define_tags.outputs.release_commit_patch }}
# "@ > $env:TEMP\patch.diff
# cat $env:TEMP\patch.diff
# cat $env:TEMP\patch.diff | git am
# windows_build_command: swift test -Xswiftc -warnings-as-errors
# linux_exclude_swift_versions: '[{"swift_version": "5.8"}, {"swift_version": "5.9"}, {"swift_version": "5.10"}, {"swift_version": "6.0"}, {"swift_version": "nightly-main"}, {"swift_version": "nightly-6.0"}]'
# windows_exclude_swift_versions: '[{"swift_version": "5.8"}, {"swift_version": "5.9"}, {"swift_version": "5.10"}, {"swift_version": "nightly"}, {"swift_version": "nightly-6.0"}]'
# create_tag:
# name: Create Tag
# runs-on: ubuntu-latest
# needs: [check_triggering_actor, test_debug, define_tags]
# permissions:
# contents: write
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Create release commits
# run: bash .github/workflows/create-release-commits.sh '${{ needs.define_tags.outputs.swift_syntax_tag }}' '${{ needs.define_tags.outputs.swift_format_version }}'
# - name: Tag release
# run: |
# git tag "${{ needs.define_tags.outputs.swift_format_version }}"
# git push origin "${{ needs.define_tags.outputs.swift_format_version }}"
# - name: Create release
# env:
# GH_TOKEN: ${{ github.token }}
# run: |
# if [[ "${{ github.event.inputs.prerelease }}" != "true" ]]; then
# # Only create a release automatically for prereleases. For real releases, release notes should be crafted by hand.
# exit
# fi
# gh release create "${{ needs.define_tags.outputs.swift_format_version }}" \
# --title "${{ needs.define_tags.outputs.swift_format_version }}" \
# --prerelease

# TODO:
# - Move create-release-commits to workflow
# - Use patch file in create_tag

0 comments on commit f87273d

Please sign in to comment.