diff options
| author | Joshua Sing <joshua@hypera.dev> | 2023-12-15 16:36:25 +1100 |
|---|---|---|
| committer | Joshua Sing <joshua@hypera.dev> | 2023-12-15 16:36:25 +1100 |
| commit | c8556c3af812f33499e607361b424c47d0fa6d2c (patch) | |
| tree | 6c18ba80f2b8ee436f1622ef175b06a8552b3eee | |
| parent | f6f90b977913fbd1951c249f6e7bbf76ea32de77 (diff) | |
| download | portable-c8556c3af812f33499e607361b424c47d0fa6d2c.tar.gz portable-c8556c3af812f33499e607361b424c47d0fa6d2c.tar.bz2 portable-c8556c3af812f33499e607361b424c47d0fa6d2c.zip | |
ci: clean up release workflow
| -rw-r--r-- | .github/scripts/changelog.sh | 74 | ||||
| -rw-r--r-- | .github/workflows/release.yml | 81 | ||||
| -rw-r--r-- | .github/workflows/release_by_tag.yml | 66 |
3 files changed, 155 insertions, 66 deletions
diff --git a/.github/scripts/changelog.sh b/.github/scripts/changelog.sh new file mode 100644 index 0000000..76492cf --- /dev/null +++ b/.github/scripts/changelog.sh | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Copyright (c) 2023 Joshua Sing <joshua@hypera.dev> | ||
| 3 | # | ||
| 4 | # Permission to use, copy, modify, and distribute this software for any | ||
| 5 | # purpose with or without fee is hereby granted, provided that the above | ||
| 6 | # copyright notice and this permission notice appear in all copies. | ||
| 7 | # | ||
| 8 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 14 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 15 | |||
| 16 | # | ||
| 17 | # Usage: changelog.sh <version> | ||
| 18 | # Reads the changelog for the specified version from the changelog file. | ||
| 19 | # The output will be reformatted for use in GitHub releases. | ||
| 20 | # | ||
| 21 | # The changelog file defaults to "ChangeLog", but can be changed by setting | ||
| 22 | # the environment variable $CHANGELOG_FILE | ||
| 23 | # | ||
| 24 | |||
| 25 | set -e | ||
| 26 | |||
| 27 | # Check if the version argument is provided | ||
| 28 | if [ "$#" -ne 1 ]; then | ||
| 29 | echo "Usage: $0 <version>" | ||
| 30 | exit 1 | ||
| 31 | fi | ||
| 32 | |||
| 33 | version="${1#v}" | ||
| 34 | changelog_file="${CHANGELOG_FILE:-ChangeLog}" | ||
| 35 | found_version=false | ||
| 36 | changelog="" | ||
| 37 | |||
| 38 | # Check if the specified changelog file exists | ||
| 39 | if [ ! -f "$changelog_file" ]; then | ||
| 40 | echo "Error: Changelog file '$changelog_file' not found" | ||
| 41 | exit 1 | ||
| 42 | fi | ||
| 43 | |||
| 44 | # Read the changelog file line by line | ||
| 45 | while IFS= read -r line; do | ||
| 46 | # Check for the version line | ||
| 47 | if echo "$line" | grep -Eq "^${version} - "; then | ||
| 48 | found_version=true | ||
| 49 | continue | ||
| 50 | fi | ||
| 51 | |||
| 52 | # Continue reading the changelog until the next version or end of file, | ||
| 53 | # skipping empty lines | ||
| 54 | if $found_version; then | ||
| 55 | echo "$line" | grep -Eq "^\s*$" && continue | ||
| 56 | echo "$line" | grep -Eq "^[0-9]+\.[0-9]+\.[0-9]+ - " && break | ||
| 57 | changelog="${changelog}${line}\n" | ||
| 58 | fi | ||
| 59 | done < "$changelog_file" | ||
| 60 | |||
| 61 | # If the specified version was not found, print an error | ||
| 62 | if ! $found_version; then | ||
| 63 | echo "Error: Version $version was not found in changelog" | ||
| 64 | exit 1 | ||
| 65 | fi | ||
| 66 | |||
| 67 | # Tidy up the changelog for displaying on GitHub | ||
| 68 | changelog=$(echo "$changelog" | sed -e 's/^\t\*/###/' -e 's/^\t//') | ||
| 69 | |||
| 70 | # Print the changelog for the specified version | ||
| 71 | echo "$changelog" | ||
| 72 | echo | ||
| 73 | echo "Full changelog: https://github.com/libressl/portable/blob/master/ChangeLog" | ||
| 74 | exit 0 | ||
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8230b82 --- /dev/null +++ b/.github/workflows/release.yml | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | # GitHub Actions workflow to create releases from tags. | ||
| 2 | name: "Release" | ||
| 3 | |||
| 4 | on: | ||
| 5 | push: | ||
| 6 | tags: [ "v*" ] | ||
| 7 | |||
| 8 | permissions: | ||
| 9 | contents: write | ||
| 10 | |||
| 11 | jobs: | ||
| 12 | release: | ||
| 13 | name: "Release" | ||
| 14 | runs-on: "ubuntu-latest" | ||
| 15 | outputs: | ||
| 16 | upload_url: "${{ steps.create_release.outputs.upload_url }}" | ||
| 17 | steps: | ||
| 18 | - name: "Checkout repository" | ||
| 19 | uses: actions/checkout@v4 | ||
| 20 | |||
| 21 | - name: "Generate version changelog" | ||
| 22 | run: .github/scripts/changelog.sh "$VERSION" > release-changelog.txt | ||
| 23 | env: | ||
| 24 | VERSION: "${{ github.ref_name }}" | ||
| 25 | |||
| 26 | - name: "Create GitHub release" | ||
| 27 | id: create_release | ||
| 28 | uses: softprops/action-gh-release@v1 | ||
| 29 | with: | ||
| 30 | body_path: "${{ github.workspace }}/release-changelog.txt" | ||
| 31 | |||
| 32 | build-windows: | ||
| 33 | name: "${{ matrix.os }}/${{ matrix.arch }}" | ||
| 34 | runs-on: "${{ matrix.os }}" | ||
| 35 | needs: ["release"] | ||
| 36 | strategy: | ||
| 37 | matrix: | ||
| 38 | os: [ "windows-2022" ] | ||
| 39 | arch: [ "Win32", "x64", "ARM64" ] | ||
| 40 | steps: | ||
| 41 | - name: "Checkout repository" | ||
| 42 | uses: actions/checkout@v4 | ||
| 43 | |||
| 44 | - name: "Setup MSYS2" | ||
| 45 | uses: msys2/setup-msys2@v2 | ||
| 46 | with: | ||
| 47 | update: true | ||
| 48 | install: >- | ||
| 49 | autoconf | ||
| 50 | automake | ||
| 51 | diffutils | ||
| 52 | libtool | ||
| 53 | gcc | ||
| 54 | git | ||
| 55 | patch | ||
| 56 | perl | ||
| 57 | |||
| 58 | - shell: msys2 {0} | ||
| 59 | run: ./autogen.sh | ||
| 60 | |||
| 61 | - shell: cmd | ||
| 62 | run: cmake -Bbuild -G "Visual Studio 17 2022" -A ${{ matrix.arch }} -DCMAKE_INSTALL_PREFIX=local | ||
| 63 | |||
| 64 | - shell: cmd | ||
| 65 | run: cmake --build build --config Release | ||
| 66 | |||
| 67 | - shell: cmd | ||
| 68 | run: cmake --install build --config Release | ||
| 69 | |||
| 70 | - shell: pwsh | ||
| 71 | run: Compress-Archive -Path local\* local.zip | ||
| 72 | |||
| 73 | - name: "Upload release artifact" | ||
| 74 | uses: actions/upload-release-asset@v1 | ||
| 75 | env: | ||
| 76 | GITHUB_TOKEN: "${{ github.token }}" | ||
| 77 | with: | ||
| 78 | upload_url: "${{ needs.release.outputs.upload_url }}" | ||
| 79 | asset_path: "local.zip" | ||
| 80 | asset_name: "libressl_${{ github.ref_name }}_windows_${{ matrix.arch }}.zip" | ||
| 81 | asset_content_type: "application/zip" | ||
diff --git a/.github/workflows/release_by_tag.yml b/.github/workflows/release_by_tag.yml deleted file mode 100644 index de05254..0000000 --- a/.github/workflows/release_by_tag.yml +++ /dev/null | |||
| @@ -1,66 +0,0 @@ | |||
| 1 | |||
| 2 | on: | ||
| 3 | push: | ||
| 4 | tags: [ "v*" ] | ||
| 5 | |||
| 6 | permissions: | ||
| 7 | contents: write | ||
| 8 | |||
| 9 | jobs: | ||
| 10 | release: | ||
| 11 | runs-on: ubuntu-latest | ||
| 12 | outputs: | ||
| 13 | upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
| 14 | steps: | ||
| 15 | - id: create_release | ||
| 16 | uses: actions/create-release@v1 | ||
| 17 | env: | ||
| 18 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| 19 | with: | ||
| 20 | tag_name: ${{ github.ref }} | ||
| 21 | release_name: Release ${{ github.ref }} | ||
| 22 | draft: false | ||
| 23 | prerelease: false | ||
| 24 | |||
| 25 | build-windows: | ||
| 26 | needs: release | ||
| 27 | strategy: | ||
| 28 | matrix: | ||
| 29 | arch: [ Win32, x64, ARM64 ] | ||
| 30 | runs-on: windows-2022 | ||
| 31 | name: windows - ${{ matrix.arch }} | ||
| 32 | steps: | ||
| 33 | - uses: msys2/setup-msys2@v2 | ||
| 34 | with: | ||
| 35 | update: true | ||
| 36 | install: >- | ||
| 37 | autoconf | ||
| 38 | automake | ||
| 39 | diffutils | ||
| 40 | libtool | ||
| 41 | gcc | ||
| 42 | git | ||
| 43 | patch | ||
| 44 | perl | ||
| 45 | - uses: actions/checkout@main | ||
| 46 | - shell: msys2 {0} | ||
| 47 | run: ./autogen.sh | ||
| 48 | - shell: cmd | ||
| 49 | run: cmake -Bbuild -G "Visual Studio 17 2022" -A ${{ matrix.arch }} -DCMAKE_INSTALL_PREFIX=local | ||
| 50 | - shell: cmd | ||
| 51 | run: cmake --build build --config Release | ||
| 52 | - shell: cmd | ||
| 53 | run: cmake --install build --config Release | ||
| 54 | - shell: pwsh | ||
| 55 | run: | | ||
| 56 | Compress-Archive -Path local\* local.zip | ||
| 57 | |||
| 58 | - name: upload release | ||
| 59 | uses: actions/upload-release-asset@v1 | ||
| 60 | env: | ||
| 61 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| 62 | with: | ||
| 63 | upload_url: ${{ needs.release.outputs.upload_url }} | ||
| 64 | asset_path: local.zip | ||
| 65 | asset_name: windows-${{ matrix.arch }}-${{ github.ref }}.zip | ||
| 66 | asset_content_type: application/zip | ||
