From 36707b03b66f0c749722b5bb430ec18eb5e89a4b Mon Sep 17 00:00:00 2001 From: Timothy Gonzalez <105177619+Timothy-Gonzalez@users.noreply.github.com> Date: Sat, 3 Feb 2024 05:35:07 -0600 Subject: [PATCH] Add release workflow --- .github/workflows/release.yaml | 94 ++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..12f4142 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,94 @@ +name: Release + +on: + push: + tags: ["v*"] + workflow_dispatch: + inputs: + tag: + description: "Specify a version tag (v#.#.#)" + required: true + +permissions: + contents: write # needed to create releases + +jobs: + create-release: + name: Create release + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: true + prerelease: false + + build: + needs: ["create-release"] + name: Build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Install clang + run: | + sudo apt-get update + sudo apt-get install -y clang + + - name: Build + run: make amalgamate + + - name: Create Release Archive + shell: bash + run: | + mkdir staging + cp amalgamate/* staging/ + cd staging + zip ../release.zip * + + - name: Prepare Asset Name + shell: bash + run: | + TAG_NAME=$( + if [ "${{ github.event_name }}" == 'workflow_dispatch' ]; then + echo "${{ github.event.inputs.tag }}"; + else + echo "${{ github.ref }}"; + fi + ) + echo "ASSET_NAME=caught-$TAG_NAME" >> $GITHUB_ENV + + - name: Upload .h to Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: amalgamate/caught.h + asset_name: caught.h + + - name: Upload .c to Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: amalgamate/caught.c + asset_name: caught.c + asset_content_type: application/octet-stream + + - name: Upload Archive as Artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ASSET_NAME }}.zip + path: release.zip