diff --git a/.github/scripts/create-tag.js b/.github/scripts/create-tag.js deleted file mode 100644 index 6ecd0bc9a8..0000000000 --- a/.github/scripts/create-tag.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = async ({ github, context }, tagName) => { - try { - await github.rest.git.createRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: `refs/tags/${tagName}`, - sha: context.sha, - force: true, - }); - } catch (err) { - console.error(`Failed to create tag: ${tagName}`); - console.error(err); - } -}; \ No newline at end of file diff --git a/.github/scripts/move-tag.js b/.github/scripts/move-tag.js deleted file mode 100644 index 580fa58e75..0000000000 --- a/.github/scripts/move-tag.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = async ({ github, context }, tagName) => { - try { - await github.rest.git.updateRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: `tags/${tagName}`, - sha: context.sha, - force: true, - }); - } catch (err) { - console.error(`Failed to move nightly tag.`); - console.error(`This should only happen the first time.`); - console.error(err); - } -}; \ No newline at end of file diff --git a/.github/scripts/prune-prereleases.js b/.github/scripts/prune-prereleases.js deleted file mode 100644 index 0537fbf138..0000000000 --- a/.github/scripts/prune-prereleases.js +++ /dev/null @@ -1,39 +0,0 @@ -module.exports = async ({ github, context }) => { - console.log("Pruning old prereleases"); - - // doc: https://docs.github.com/en/rest/releases/releases - const { data: releases } = await github.rest.repos.listReleases({ - owner: context.repo.owner, - repo: context.repo.repo, - }); - - let nightlies = releases.filter( - release => - // Only consider releases tagged `nightly-${SHA}` for deletion - release.tag_name.includes("nightly") && - release.tag_name !== "nightly" && - // ref: https://github.com/foundry-rs/foundry/issues/3881 - // Skipping pruning the build on 1st day of each month - !release.created_at.includes("-01T") - ); - - // Keep newest 3 nightlies - nightlies = nightlies.slice(3); - - for (const nightly of nightlies) { - console.log(`Deleting nightly: ${nightly.tag_name}`); - await github.rest.repos.deleteRelease({ - owner: context.repo.owner, - repo: context.repo.repo, - release_id: nightly.id, - }); - console.log(`Deleting nightly tag: ${nightly.tag_name}`); - await github.rest.git.deleteRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: `tags/${nightly.tag_name}`, - }); - } - - console.log("Done."); -}; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1d949da2a..abd5c036bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,6 @@ jobs: image: ghcr.io/dojoengine/dojo-dev:448ffda steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - uses: Swatinem/rust-cache@v2 - run: cargo llvm-cov nextest --all-features --lcov --output-path lcov.info - uses: codecov/codecov-action@v3 @@ -84,8 +82,6 @@ jobs: image: ghcr.io/dojoengine/dojo-dev:448ffda steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - uses: Swatinem/rust-cache@v2 - run: scripts/clippy.sh @@ -104,8 +100,6 @@ jobs: image: ghcr.io/dojoengine/dojo-dev:448ffda steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - uses: Swatinem/rust-cache@v2 - run: > scripts/docs.sh diff --git a/.github/workflows/release-dispatch.yml b/.github/workflows/release-dispatch.yml index 60585445d5..b0917f9f44 100644 --- a/.github/workflows/release-dispatch.yml +++ b/.github/workflows/release-dispatch.yml @@ -20,6 +20,8 @@ jobs: - uses: actions/checkout@v3 - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - run: cargo release version ${{ inputs.version }} --execute --no-confirm && cargo release replace --execute --no-confirm + - id: changelog + uses: mikepenz/release-changelog-builder-action@v4.1.0 - uses: peter-evans/create-pull-request@v5 with: # We have to use a PAT in order to trigger ci @@ -29,3 +31,4 @@ jobs: branch: prepare-release base: main delete-branch: true + body: ${{steps.changelog.outputs.changelog}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1af6f7d2f..fe9d0d75a0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,81 +1,29 @@ name: release on: - push: - tags: - - "*" - schedule: - - cron: "0 0 * * *" - workflow_dispatch: + pull_request: + types: [closed] + branches: + - main env: - IS_NIGHTLY: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && 'true' || 'false' }} CARGO_TERM_COLOR: always RUST_VERSION: 1.70.0 REGISTRY_IMAGE: ghcr.io/${{ github.repository }} jobs: prepare: - name: Prepare release + if: github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'prepare-release' runs-on: ubuntu-latest - outputs: tag_name: ${{ steps.release_info.outputs.tag_name }} - release_name: ${{ steps.release_info.outputs.release_name }} - changelog: ${{ steps.build_changelog.outputs.changelog }} - steps: - - name: Checkout sources - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Compute release name and tag + - uses: actions/checkout@v3 + - name: Get version id: release_info run: | - if [[ $IS_NIGHTLY == "true" ]]; then - echo "tag_name=nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT - echo "release_name=Nightly ($(date '+%Y-%m-%d'))" >> $GITHUB_OUTPUT - else - echo "tag_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT - echo "release_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT - fi - - - name: Check version - run: | - if [[ $IS_NIGHTLY != "true" ]]; then - cargo install cargo-get - VERSION=$(cargo get workspace.package.version) - TAG=${{ steps.release_info.outputs.tag_name }} - if [[ "v$VERSION" != "$TAG" ]]; then - echo "Version in Cargo.toml ($VERSION) does not match release tag ($TAG)" - exit 1 - fi - fi - - # Creates a `nightly-SHA` tag for this specific nightly - # This tag is used for this specific nightly version's release - # which allows users to roll back. It is also used to build - # the changelog. - - name: Create build-specific nightly tag - if: ${{ env.IS_NIGHTLY == 'true' }} - uses: actions/github-script@v5 - env: - TAG_NAME: ${{ steps.release_info.outputs.tag_name }} - with: - script: | - const createTag = require('./.github/scripts/create-tag.js') - await createTag({ github, context }, process.env.TAG_NAME) - - - name: Build changelog - id: build_changelog - uses: mikepenz/release-changelog-builder-action@v2 - with: - configuration: "./.github/changelog.json" - fromTag: ${{ env.IS_NIGHTLY == 'true' && 'nightly' || '' }} - toTag: ${{ steps.release_info.outputs.tag_name }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + cargo install cargo-get + echo "tag_name=$(cargo get workspace.package.version)" >> $GITHUB_OUTPUT release: name: ${{ matrix.job.target }} (${{ matrix.job.os }}) @@ -152,7 +100,7 @@ jobs: - name: Archive binaries id: artifacts env: - VERSION_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }} + VERSION_NAME: ${{ needs.prepare.outputs.tag_name }} run: | if [ "$PLATFORM_NAME" == "linux" ]; then tar -czvf "dojo_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release katana sozo torii dojo-language-server @@ -174,23 +122,9 @@ jobs: - name: Create release uses: softprops/action-gh-release@v1 with: - name: ${{ needs.prepare.outputs.release_name }} + name: ${{ github.event.pull_request.title }} tag_name: ${{ needs.prepare.outputs.tag_name }} - prerelease: ${{ env.IS_NIGHTLY == 'true' }} - body: ${{ needs.prepare.outputs.changelog }} - files: | - ${{ steps.artifacts.outputs.file_name }} - - # If this is a nightly release, it also updates the release - # tagged `nightly` for compatibility with `dojoup` - - name: Update nightly release - if: ${{ env.IS_NIGHTLY == 'true' }} - uses: softprops/action-gh-release@v1 - with: - name: "Nightly" - tag_name: "nightly" - prerelease: true - body: ${{ needs.prepare.outputs.changelog }} + body: ${{ github.event.pull_request.body }} files: | ${{ steps.artifacts.outputs.file_name }} @@ -212,31 +146,6 @@ jobs: path: ${{ env.PLATFORM_NAME }} retention-days: 1 - cleanup: - name: Release cleanup - runs-on: ubuntu-latest - needs: release - - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - # Moves the `nightly` tag to `HEAD` - - name: Move nightly tag - if: ${{ env.IS_NIGHTLY == 'true' }} - uses: actions/github-script@v5 - with: - script: | - const moveTag = require('./.github/scripts/move-tag.js') - await moveTag({ github, context }, 'nightly') - - - name: Delete old nightlies - uses: actions/github-script@v5 - with: - script: | - const prunePrereleases = require('./.github/scripts/prune-prereleases.js') - await prunePrereleases({github, context}) - docker-build-and-push: name: Build and push docker image runs-on: ubuntu-latest-4-cores diff --git a/dojoup/dojoup b/dojoup/dojoup index a0e7e2c871..f07f251028 100755 --- a/dojoup/dojoup +++ b/dojoup/dojoup @@ -88,8 +88,6 @@ main() { | tr -d '"' \ | head -n 1) DOJOUP_VERSION=$DOJOUP_TAG - elif [[ "$DOJOUP_VERSION" == nightly* ]]; then - DOJOUP_VERSION="nightly" elif [[ "$DOJOUP_VERSION" == [[:digit:]]* ]]; then # Add v prefix DOJOUP_VERSION="v${DOJOUP_VERSION}" @@ -288,8 +286,9 @@ banner() { Repo : https://github.com/dojoengine/dojo - Book : https://book.dojoengine.org/ - Chat : https://t.me/+DJxNYR3rsfJmZTg1 + Book : https://book.dojoengine.org/ + Chat : https://discord.gg/dojoengine + https://t.me/dojoengine ═════════════════════════════════════════════════════════════════════════