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

ci: clean up release workflow #976

Merged
merged 1 commit into from
Dec 18, 2023
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
74 changes: 74 additions & 0 deletions .github/scripts/changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/sh
# Copyright (c) 2023 Joshua Sing <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

#
# Usage: changelog.sh <version>
# Reads the changelog for the specified version from the changelog file.
# The output will be reformatted for use in GitHub releases.
#
# The changelog file defaults to "ChangeLog", but can be changed by setting
# the environment variable $CHANGELOG_FILE
#

set -e

# Check if the version argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <version>"
exit 1
fi

version="${1#v}"
changelog_file="${CHANGELOG_FILE:-ChangeLog}"
found_version=false
changelog=""

# Check if the specified changelog file exists
if [ ! -f "$changelog_file" ]; then
echo "Error: Changelog file '$changelog_file' not found"
exit 1
fi

# Read the changelog file line by line
while IFS= read -r line; do
# Check for the version line
if echo "$line" | grep -Eq "^${version} - "; then
found_version=true
continue
fi

# Continue reading the changelog until the next version or end of file,
# skipping empty lines
if $found_version; then
echo "$line" | grep -Eq "^\s*$" && continue
echo "$line" | grep -Eq "^[0-9]+\.[0-9]+\.[0-9]+ - " && break
changelog="${changelog}${line}\n"
fi
done < "$changelog_file"

# If the specified version was not found, print an error
if ! $found_version; then
echo "Error: Version $version was not found in changelog"
exit 1
fi

# Tidy up the changelog for displaying on GitHub
changelog=$(echo "$changelog" | sed -e 's/^\t\*/###/' -e 's/^\t//')

# Print the changelog for the specified version
echo "$changelog"
echo
echo "Full changelog: https://github.com/libressl/portable/blob/master/ChangeLog"
exit 0
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# GitHub Actions workflow to create releases from tags.
name: "Release"

on:
push:
tags: [ "v*" ]

permissions:
contents: write

jobs:
release:
name: "Release"
runs-on: "ubuntu-latest"
outputs:
upload_url: "${{ steps.create_release.outputs.upload_url }}"
steps:
- name: "Checkout repository"
uses: actions/checkout@v4

- name: "Generate version changelog"
run: .github/scripts/changelog.sh "$VERSION" > release-changelog.txt
env:
VERSION: "${{ github.ref_name }}"

- name: "Create GitHub release"
id: create_release
uses: softprops/action-gh-release@v1
with:
body_path: "${{ github.workspace }}/release-changelog.txt"

build-windows:
name: "${{ matrix.os }}/${{ matrix.arch }}"
runs-on: "${{ matrix.os }}"
needs: ["release"]
strategy:
matrix:
os: [ "windows-2022" ]
arch: [ "Win32", "x64", "ARM64" ]
steps:
- name: "Checkout repository"
uses: actions/checkout@v4

- name: "Setup MSYS2"
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
autoconf
automake
diffutils
libtool
gcc
git
patch
perl

- shell: msys2 {0}
run: ./autogen.sh

- shell: cmd
run: cmake -Bbuild -G "Visual Studio 17 2022" -A ${{ matrix.arch }} -DCMAKE_INSTALL_PREFIX=local

- shell: cmd
run: cmake --build build --config Release

- shell: cmd
run: cmake --install build --config Release

- shell: pwsh
run: Compress-Archive -Path local\* local.zip

- name: "Upload release artifact"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: "${{ github.token }}"
with:
upload_url: "${{ needs.release.outputs.upload_url }}"
asset_path: "local.zip"
asset_name: "libressl_${{ github.ref_name }}_windows_${{ matrix.arch }}.zip"
asset_content_type: "application/zip"
66 changes: 0 additions & 66 deletions .github/workflows/release_by_tag.yml

This file was deleted.