Skip to content

Commit

Permalink
Add release workflow (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
keeshux authored Mar 24, 2024
1 parent 50fa02d commit 53316e5
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 9 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Binary Release

on:
push:
branches:
- 'master'
paths:
- '.version'

env:
FRAMEWORK_ARTIFACT: "wg-go.xcframework"

jobs:
publish_binary_release:
name: Publish binary release
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "15.2"
- uses: actions/setup-go@v5
with:
go-version: "stable"
- name: Build framework
id: framework
timeout-minutes: 10
run: |
COMPOUND_VERSION=`cat .version`
LIBRARY_VERSION=${COMPOUND_VERSION%-*}
LIBRARY_MINOR=${LIBRARY_VERSION%.*}
LIBRARY_PATCH=${LIBRARY_VERSION##*.}
SCRIPT_VERSION=${COMPOUND_VERSION#*-}
MERGED_PATCH=$((($LIBRARY_PATCH + 1) * 100 + $SCRIPT_VERSION))
TAG_NAME="$LIBRARY_MINOR.$MERGED_PATCH"
./build-platforms.sh
./create-framework.sh
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
echo "library_version=$LIBRARY_VERSION" >> $GITHUB_OUTPUT
echo "script_version=$SCRIPT_VERSION" >> $GITHUB_OUTPUT
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
git_push_gpgsign: false
- name: Update package
id: package
env:
TAG_NAME: ${{ steps.framework.outputs.tag }}
LIBRARY_VERSION: ${{ steps.framework.outputs.library_version }}
SCRIPT_VERSION: ${{ steps.framework.outputs.script_version }}
PACKAGE_ZIP: ${{ env.FRAMEWORK_ARTIFACT }}.zip
PACKAGE_CHECKSUM: ${{ env.FRAMEWORK_ARTIFACT }}.zip.checksum
PACKAGE_METADATA: "Package.swift"
run: |
zip -yr "$PACKAGE_ZIP" "$FRAMEWORK_ARTIFACT"
CHECKSUM=`swift package compute-checksum "$PACKAGE_ZIP"`
echo $CHECKSUM >$PACKAGE_CHECKSUM
sed -E "s@/[0-9\.]*/${PACKAGE_ZIP}@/${TAG_NAME}/\\1@" $PACKAGE_METADATA |
sed -E "s/checksum: \"[0-9a-f]*\"/checksum: \"${CHECKSUM}\"/" >$PACKAGE_METADATA.tmp
mv $PACKAGE_METADATA.tmp $PACKAGE_METADATA
RELEASE_NAME="$LIBRARY_VERSION"
if [ $SCRIPT_VERSION -gt 0 ]; then
RELEASE_NAME="$RELEASE_NAME ($SCRIPT_VERSION)"
fi
git add $PACKAGE_METADATA
git commit -m "$RELEASE_NAME"
git tag "$TAG_NAME" -m "$RELEASE_NAME"
git push && git push --tags
echo "release_name=$RELEASE_NAME" >> $GITHUB_OUTPUT
echo "checksum=$PACKAGE_CHECKSUM" >> $GITHUB_OUTPUT
- name: Publish release
uses: softprops/action-gh-release@v1
with:
name: ${{ steps.package.outputs.release_name }}
tag_name: ${{ steps.framework.outputs.tag }}
generate_release_notes: true
files: |
${{ steps.framework.outputs.artifact }}
${{ steps.package.outputs.checksum }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
build/
.cache/
.tmp/
out/
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.19-1
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion build-platforms.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
WG_GO_PATH="src"
WG_GO_PATH="."
BUILD_PATH="build"
FRAMEWORK_PATH="$BUILD_PATH/wg-go.xcframework"

Expand Down
2 changes: 1 addition & 1 deletion create-framework.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
PLATFORMS_PATH="build"
FRAMEWORK_PATH="build/wg-go.xcframework"
FRAMEWORK_PATH="wg-go.xcframework"

PLATFORMS=("iphoneos" "iphonesimulator" "macosx" "appletvos" "appletvsimulator")
for ARG in ${PLATFORMS[@]}; do
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions src/.gitignore

This file was deleted.

6 changes: 2 additions & 4 deletions update-package.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash

# FIXME: tag name should embed wg version + script version
if [[ -z $1 ]]; then
echo "Provide a tag"
exit 1
Expand All @@ -10,8 +8,8 @@ TAG_NAME="$1"
FRAMEWORK_PATH="wg-go.xcframework"
MANIFEST="Package.swift"

zip -yr "build/$FRAMEWORK_PATH.zip" "build/$FRAMEWORK_PATH"
CHECKSUM=`swift package compute-checksum build/$FRAMEWORK_PATH.zip`
zip -yr "$FRAMEWORK_PATH.zip" "$FRAMEWORK_PATH"
CHECKSUM=`swift package compute-checksum $FRAMEWORK_PATH.zip`

sed -E "s@/[0-9\.]*/($FRAMEWORK_PATH.zip)@/$TAG_NAME/\\1@" $MANIFEST | sed -E "s/checksum: \"[0-9a-f]*\"/checksum: \"$CHECKSUM\"/" >$MANIFEST.tmp
mv $MANIFEST.tmp $MANIFEST
File renamed without changes.

0 comments on commit 53316e5

Please sign in to comment.