From a3cd07e6f6a3f02b2ef11793d330c4f70e4aa400 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 1 Jul 2023 14:31:04 +0200 Subject: [PATCH] Change: [CI] switch to reusing workflows (#85) --- .github/workflows/publish.yml | 156 ---------------------------------- .github/workflows/release.yml | 20 +++++ .github/workflows/testing.yml | 59 ++----------- 3 files changed, 28 insertions(+), 207 deletions(-) delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 7cc5439..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,156 +0,0 @@ -name: Publish binaries - -on: - release: - types: - - published - schedule: - - cron: '0 21 * * *' - workflow_dispatch: - -concurrency: - group: release - cancel-in-progress: false - -jobs: - publish_binaries: - name: Publish binaries - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set variables - shell: bash - id: vars - run: | - FULL_VERSION=$(./findversion.sh) - RELEASE_DATE=$(TZ='UTC' date +"%Y-%m-%d %H:%M UTC") - VERSION=$(echo "${FULL_VERSION}" | cut -f 1 -d$'\t') - IS_TAG=$(echo "${FULL_VERSION}" | cut -f 5 -d$'\t') - - # If this secret is not set, we are doing a dryrun. This means that - # people who fork this repository will not try to publish this to AWS - # (as that will most likely fail anyway). - if [ -z "${{ secrets.CDN_S3_BUCKET }}" ]; then - DRY_RUN="true" - else - DRY_RUN="false" - fi - - REPO_NAME=$(echo ${{ github.repository }} | cut -d/ -f2 | tr [A-Z] [a-z]) - # If we run on "schedule", we are producting a nightly. Otherwise it - # is a tag, so a release. - if [ "${{ github.event_name }}" = "schedule" ]; then - FOLDER="${REPO_NAME}-nightlies" - - # Download the latest version we published; if we are different, it - # is safe to assume we are newer. - LATEST_VERSION=$(curl --fail -s https://cdn.openttd.org/${FOLDER}/latest.yaml | grep version | cut -d: -f2 | cut -b 2-) - - if [ "${IS_TAG}" = "1" ]; then - echo "Run on schedule; going to skip this run, last change was released" - SKIP="true" - elif [ "${LATEST_VERSION}" = "${VERSION}" ]; then - echo "Run on schedule; going to skip this run, as we already build this version" - SKIP="true" - elif [ "${DRY_RUN}" = "true" ]; then - # Also skip everything if we are triggered frm the schedule and we - # are a fork. That would waste a lot of CPU cycles for no good reason. - echo "Run on schedule; going to skip this run, as this is a fork" - SKIP="true" - else - SKIP="false" - fi - else - FOLDER="${REPO_NAME}-releases" - SKIP="false" - fi - - echo "release-date=${RELEASE_DATE}" >> $GITHUB_OUTPUT - echo "version=${VERSION}" >> $GITHUB_OUTPUT - echo "folder=${FOLDER}" >> $GITHUB_OUTPUT - echo "dry-run=${DRY_RUN}" >> $GITHUB_OUTPUT - echo "skip=${SKIP}" >> $GITHUB_OUTPUT - - echo "Release-date: ${RELEASE_DATE}" - echo "Version: ${VERSION}" - echo "Folder: ${FOLDER}" - echo "Dry-run: ${DRY_RUN}" - echo "Skip: ${SKIP}" - - - if: steps.vars.outputs.skip == 'false' - name: Set up Python 3.8 - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - - if: steps.vars.outputs.skip == 'false' - name: Install dependencies - shell: bash - run: | - sudo apt update - sudo apt install -y gimp grfcodec --no-install-recommends - - python -m pip install --upgrade pip - python -m pip install nml - - - if: steps.vars.outputs.skip == 'false' - name: Build - shell: bash - run: | - make maintainer-clean - make bundle_zip bundle_xsrc - - # Move bundles in their own folder - mkdir bundles - mv opengfx-${{ steps.vars.outputs.version }}-source.tar.xz bundles/ - mv opengfx-${{ steps.vars.outputs.version }}-all.zip bundles/ - - - if: steps.vars.outputs.skip == 'false' - name: Create checksums - shell: bash - run: | - cd bundles - for i in $(ls); do - openssl dgst -r -md5 -hex $i > $i.md5sum - openssl dgst -r -sha1 -hex $i > $i.sha1sum - openssl dgst -r -sha256 -hex $i > $i.sha256sum - done - - # Show the content of the bundles folder, to make problems debugging easier - ls -l - - - if: steps.vars.outputs.skip == 'false' - name: Prepare bundles folder - shell: bash - run: | - echo "${{ steps.vars.outputs.release-date }}" > bundles/released.txt - cp README.md bundles/ - cp changelog.txt bundles/ - - # Show the content of the bundles folder, to make problems debugging easier - ls -l bundles/ - - - if: steps.vars.outputs.dry-run == 'false' && steps.vars.outputs.skip == 'false' - name: Publish - id: publish - shell: bash - run: | - aws s3 cp --recursive --only-show-errors bundles/ s3://${{ secrets.CDN_S3_BUCKET }}/${{ steps.vars.outputs.folder }}/${{ steps.vars.outputs.version }}/ - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} - - - if: steps.vars.outputs.dry-run == 'false' && steps.vars.outputs.skip == 'false' - name: Trigger 'update CDN' - uses: peter-evans/repository-dispatch@v1 - with: - token: ${{ secrets.DEPLOYMENT_TOKEN }} - repository: OpenTTD/workflows - event-type: update-cdn - client-payload: '{"version": "${{ steps.vars.outputs.version }}", "folder": "${{ steps.vars.outputs.folder }}"}' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b7ec93f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,20 @@ +name: Release + +on: + release: + types: + - published + schedule: + - cron: '0 21 * * *' + workflow_dispatch: + +jobs: + release: + name: Release + uses: OpenTTD/actions/.github/workflows/rw-entry-release-baseset.yml@v4 + secrets: inherit + with: + apt-packages: gimp grfcodec + name: opengfx + pip-packages: nml + problem-matcher: .github/workflows/nml-problem-matcher.json diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 51f6da0..3e5adef 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -8,55 +8,12 @@ on: branches: - master -concurrency: - group: testing-${{ github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} - jobs: - build: - name: Build OpenGFX - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Python 3.8 - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - - name: Install dependencies - shell: bash - run: | - sudo apt update - sudo apt install -y gimp grfcodec --no-install-recommends - - python -m pip install --upgrade pip - python -m pip install nml - - - name: Install NML problem matcher - shell: bash - run: | - echo "::add-matcher::.github/workflows/nml-problem-matcher.json" - - - name: Build - shell: bash - run: | - make maintainer-clean - make bundle_tar bundle_src - - check_annotations: - name: Check Annotations - needs: - - build - - if: always() && github.event_name == 'pull_request' - - runs-on: ubuntu-latest - - steps: - - name: Check annotations - uses: OpenTTD/actions/annotation-check@v4 + testing: + name: Testing + uses: OpenTTD/actions/.github/workflows/rw-entry-testing-baseset.yml@v4 + with: + apt-packages: gimp grfcodec + name: opengfx + pip-packages: nml + problem-matcher: .github/workflows/nml-problem-matcher.json