diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 0fdfa5d..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Release - -on: - push: - tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 - -jobs: - release: - name: Create Github Release - if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-latest - steps: - - - name: ๐Ÿ“ฅ Checkout repository - uses: actions/checkout@v4 - - - name: ๐Ÿญ Create Release - run: | - gh release create ${{ github.ref_name }} --generate-notes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # - name: โซ Upload to Hackage - # id: upload_hackage - # env: - # HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }} - # uses: freckle/stack-upload-action@main diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ac0c5b9..374e282 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,8 @@ on: jobs: build-and-test: - runs-on: ${{ matrix.os }} + name: Build and Test + runs-on: ${{ matrix.os }} strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest, macos-13] @@ -67,6 +68,19 @@ jobs: echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}" echo GHC_VERSION="${GHC_VERSION}" >> "${GITHUB_ENV}" + - name: ๐Ÿ’พ Cache Haskell toolchain + if: runner.os == 'macOS' + uses: actions/cache@v4 + with: + path: | + ~/.ghcup + ~/.stack/programs + ~/.stack/pantry + key: ${{ runner.os }}-${{ runner.arch }}-haskell-${{ env.GHC_VERSION }}-stack-latest + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-haskell-${{ env.GHC_VERSION }}- + ${{ runner.os }}-${{ runner.arch }}-haskell- + - name: ๐Ÿ— Setup Haskell if : runner.os == 'macOS' uses: haskell-actions/setup@v2 @@ -299,45 +313,23 @@ jobs: mv zip/"$($env:ARTEFACT).zip" . - name: ๐Ÿงช Run tests - run: stack test $STACK_YAML_ARG --ta --als-path=zip/als - - # release (optional) - - name: ๐Ÿšข Release Artifacts (stable) - if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release upload ${{ github.ref_name }} $ARTEFACT.zip --clobber + run: stack test $STACK_YAML_ARG - # dev release (optional) - - name: ๐Ÿšข Create/Update Dev Release - if: github.ref == 'refs/heads/dev' && matrix.agda == 'Agda-2.8.0' && matrix.os == 'ubuntu-latest' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Delete existing dev release if it exists - gh release delete dev --cleanup-tag -y || true - - # Create new dev pre-release - gh release create dev \ - --title "Development Release (dev)" \ - --notes "Development pre-release build from latest changes. This is a pre-release for testing purposes." \ - --prerelease - - - name: ๐Ÿ“ค Upload artifacts to dev release - if: github.ref == 'refs/heads/dev' && matrix.agda == 'Agda-2.8.0' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload dev $ARTEFACT.zip --clobber + - name: ๐Ÿ“ค Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARTEFACT }} + path: ${{ env.ARTEFACT }}.zip + retention-days: 1 build-wasm: name: Build WASM - if: github.ref == 'refs/heads/dev' + if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' runs-on: ubuntu-22.04 env: GHC_WASM_META_FLAVOUR: '9.10' - GHC_WASM_META_COMMIT_HASH: '7927129e42bcd6a54b9e06e26455803fa4878261' + GHC_WASM_META_COMMIT_HASH: 'c3f44696d29aaeadd755d69c51735954bfcd59db' steps: - uses: actions/checkout@v4 @@ -354,6 +346,8 @@ jobs: with: path: ~/.ghc-wasm key: ghc-wasm-${{ env.CI_CACHE_KEY }} + restore-keys: | + ghc-wasm-${{ runner.os }}-${{ runner.arch }}- - name: Try to restore cached native cabal id: native-cabal-cache-restore @@ -363,15 +357,17 @@ jobs: ~/.config/cabal ~/.cache/cabal key: native-cabal-${{ env.CI_CACHE_KEY }} + restore-keys: | + native-cabal-${{ runner.os }}-${{ runner.arch }}- - name: Try to restore cached dist-newstyle id: dist-newstyle-cache-restore uses: actions/cache/restore@v4 with: path: als/dist-newstyle - key: dist-newstyle-${{ env.CI_CACHE_KEY }}-${{ hashFiles('als/dist-newstyle/**') }} + key: dist-newstyle-${{ env.CI_CACHE_KEY }} restore-keys: | - dist-newstyle-${{ env.CI_CACHE_KEY }}- + dist-newstyle-${{ runner.os }}-${{ runner.arch }}- - name: Clone and setup ghc-wasm-meta id: ghc-wasm-setup @@ -407,27 +403,19 @@ jobs: mv cabal.project.wasm32 cabal.project wasm32-wasi-cabal configure --flag=Agda-2-8-0 - - name: 'Build dep: lsp-types' - uses: nick-fields/retry@v3 - id: build-dep-lsp-types - with: - timeout_minutes: 10 - max_attempts: 2 - command: cd als && wasm32-wasi-cabal build lib:lsp-types - - - name: 'Build dep: agda' + - name: Build Agda as dependency id: build-dep-agda working-directory: './als' run: wasm32-wasi-cabal build lib:agda - name: Cache dist-newstyle uses: actions/cache/save@v4 - if: steps.build-dep-lsp-types.outcome == 'success' && steps.build-dep-agda.outcome == 'success' + if: steps.build-dep-agda.outcome == 'success' with: path: als/dist-newstyle - key: dist-newstyle-${{ env.CI_CACHE_KEY }}-${{ hashFiles('als/dist-newstyle/**') }} + key: dist-newstyle-${{ env.CI_CACHE_KEY }} - - name: Build dependencies + - name: Build dependencies other than Agda working-directory: './als' run: | # Setup network submodule autotools @@ -466,17 +454,108 @@ jobs: path: ~/.ghc-wasm key: ${{ steps.ghc-wasm-cache-restore.outputs.cache-primary-key }} - - name: ๐Ÿ“ค Upload WASM to dev release + - name: ๐Ÿ“ค Upload WASM artifact + uses: actions/upload-artifact@v4 + with: + name: als-dev-wasm + path: ~/out/${{ env.WASM_BINARY_NAME }} + retention-days: 1 + + create-release: + name: Create Release + needs: [build-and-test, build-wasm] + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci') + runs-on: ubuntu-latest + steps: + + - name: ๐Ÿ“ฅ Checkout repository + uses: actions/checkout@v4 + + - name: ๐Ÿญ Create Stable Release + if: startsWith(github.ref, 'refs/tags/v') + run: | + gh release create ${{ github.ref_name }} --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: ๐Ÿšข Create/Update Dev Release + if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - cd ~/out - ls -la - echo "Looking for WASM binary: $WASM_BINARY_NAME" - if [ -f "$WASM_BINARY_NAME" ]; then - mv "$WASM_BINARY_NAME" als-dev-wasm - gh release upload dev als-dev-wasm --clobber --repo ${{ github.repository }} - else - echo "WASM binary '$WASM_BINARY_NAME' not found in ~/out" - exit 1 - fi \ No newline at end of file + # Delete existing dev release if it exists + gh release delete dev --cleanup-tag -y || true + + # Wait for GitHub to process the deletion to avoid race condition + # that causes releases to be created as drafts + # See: https://github.com/cli/cli/issues/8458 + sleep 5 + + # Create new dev pre-release + gh release create dev \ + --title "Development Release (dev)" \ + --notes "Development pre-release build from latest changes. This is a pre-release for testing purposes." \ + --prerelease + + upload-stable-release: + name: Upload to Stable Release + needs: create-release + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + + - name: ๐Ÿ“ฅ Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: ๐Ÿšข Upload artifacts to release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd artifacts + for dir in */; do + artifact_name="${dir%/}" + echo "Uploading ${artifact_name}..." + if [ -f "${artifact_name}/${artifact_name}.zip" ]; then + gh release upload ${{ github.ref_name }} "${artifact_name}/${artifact_name}.zip" --clobber --repo ${{ github.repository }} + else + echo "Warning: No .zip file found in ${artifact_name}" + fi + done + + upload-dev-release: + name: Upload to Dev Release + needs: create-release + if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/ci' + runs-on: ubuntu-latest + steps: + + - name: ๐Ÿ“ฅ Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: ๐Ÿšข Upload artifacts to dev release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd artifacts + # Upload only Agda-2.8.0 artifacts and WASM + for dir in *Agda-2.8.0* als-dev-wasm; do + if [ -d "$dir" ]; then + artifact_name="$dir" + echo "Uploading ${artifact_name}..." + if [ -f "${artifact_name}/${artifact_name}.zip" ]; then + gh release upload dev "${artifact_name}/${artifact_name}.zip" --clobber --repo ${{ github.repository }} + elif [ "$artifact_name" = "als-dev-wasm" ]; then + # Find the WASM binary (filename may vary) + wasm_file=$(find "${artifact_name}" -type f -name "als*" | head -1) + if [ -n "$wasm_file" ]; then + gh release upload dev "$wasm_file" --clobber --repo ${{ github.repository }} + else + echo "Warning: WASM binary not found in ${artifact_name}" + fi + fi + fi + done \ No newline at end of file