From 561111c37e2e8ccbdefd88456893b2f56f95d7fc Mon Sep 17 00:00:00 2001 From: Fabricio Olivetti de Franca Date: Wed, 4 Sep 2024 17:55:40 -0300 Subject: [PATCH] Create release.yml --- .github/workflows/release.yml | 93 +++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..80292bb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,93 @@ +name: srtols Release + +on: push + # Trigger the workflow on the new 'v*' tag created + #push: + # tags: + # - "v*" + +jobs: + create_release: + name: Create Github 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.1.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: true + prerelease: false + + build_artifact: + needs: [create_release] + name: ${{ matrix.os }}/GHC ${{ matrix.ghc }}/${{ github.ref }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + ghc: + - 9.6.6 + cabal: ["3.12.1.0"] + defaults: + run: + shell: bash + + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Set tag name + uses: olegtarasov/get-tag@v2.1 + id: tag + with: + tagRegex: "v(.*)" + tagRegexGroup: 1 + + - name: Setup Haskell + uses: haskell/actions/setup@v2 + id: setup-haskell-cabal + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + + - name: Cache ~/.cabal/store + uses: actions/cache@v2 + with: + key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ github.sha }} + path: ~/.cabal/store + + - name: Build binary + run: | + mkdir dist + cabal install exe:srsimplify --install-method=copy --overwrite-policy=always --installdir=dist + cabal install exe:srtools --install-method=copy --overwrite-policy=always --installdir=dist + + - if: matrix.os == 'windows-latest' + name: Set extension to .exe on Windows + run: echo "EXT=.exe" >> $GITHUB_ENV + + - name: Set binary path name + run: | + echo "BINARY_PATH1=./dist/srsimplify${{ env.EXT }}" >> $GITHUB_ENV + echo "BINARY_PATH2=./dist/srtools${{ env.EXT }}" >> $GITHUB_ENV + + - name: Compress binary + uses: svenstaro/upx-action@2.0.1 + with: + file: ${{ env.BINARY_PATH }} + + - name: Upload Release Asset + id: upload-release-asset + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + ${{ env.BINARY_PATH1 }}/srsimplify-${{ steps.tag.outputs.tag }}-${{ runner.os }}-ghc-${{ matrix.ghc }}${{ env.EXT }} + ${{ env.BINARY_PATH2 }}/srtools-${{ steps.tag.outputs.tag }}-${{ runner.os }}-ghc-${{ matrix.ghc }}${{ env.EXT }}