From 6327fa27e6af0335cc301b9d50caf308e7f77c18 Mon Sep 17 00:00:00 2001 From: tree Date: Sun, 5 Feb 2023 14:53:01 +0100 Subject: [PATCH] Package releases --- .github/workflows/deploy.yml | 87 +++++++++++++++++++++++++++--------- .gitignore | 1 + .woodpecker.yml | 7 +-- Makefile | 3 ++ README.md | 3 +- utils/tag.js | 9 ++++ 6 files changed, 85 insertions(+), 25 deletions(-) create mode 100644 utils/tag.js diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0120765..e025953 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,37 +1,82 @@ name: Test, build, deploy +env: + ENTRY: 23 + GH_PAGES_DOMAIN: data.prgblockweek.com on: push: branches: - - main # Set a branch to deploy - pull_request: + - main jobs: - deploy: + build: runs-on: ubuntu-latest - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + outputs: + tag: ${{ env.TAG }} steps: - - name: Setup repo - uses: actions/checkout@v3 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Setup Deno - #uses: denoland/setup-deno@v1 - uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 + - uses: denoland/setup-deno@v1 with: deno-version: v1.x - uses: szenius/set-timezone@v1.0 with: timezoneLinux: "Europe/Prague" - - name: Build sources - run: make - # - name: Build changelog - # run: make changelog - - name: List ./dist - run: find dist - - name: Add custom domain - run: "touch dist/CNAME && echo \"data.prgblockweek.com\" >> dist/CNAME" - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 + - run: make + - run: find dist + - run: "deno run --allow-run utils/tag.js >> $GITHUB_ENV" + - run: "echo \"${{ env.TAG }}\" >> ./dist/TAG" + - run: "echo \"Builded Tag: ${{ env.TAG }}\"" + - uses: montudor/action-zip@v1 + - run: "zip -qq -r release.zip dist" + - uses: actions/upload-artifact@v3 + with: + name: release + path: release.zip + release: + needs: [build] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - run: "echo \"TAG=${{ needs.build.outputs.tag }}\" >> $GITHUB_ENV" + - run: "echo \"Tag: ${{ env.TAG }}\"" + - uses: actions/download-artifact@v3 + with: + name: release + - uses: montudor/action-zip@v1 + - run: unzip -qq release.zip + - run: "zip -qq -r ../pbw-${{ env.ENTRY }}-${{ env.TAG }}.zip ${{ env.ENTRY }}" + working-directory: ./dist + - uses: rickstaa/action-create-tag@v1 + with: + tag: "${{ env.TAG }}" + message: "Latest release" + github_token: '${{ secrets.GITHUB_TOKEN }}' + - uses: softprops/action-gh-release@v1 + with: + tag_name: "${{ env.TAG }}" + name: "${{ env.TAG }}" + body: "This is a automated release." + draft: false + prerelease: false + files: | + pbw-${{ env.ENTRY }}-${{ env.TAG }}.zip + pages: + needs: [build] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: release + - uses: montudor/action-zip@v1 + - run: unzip -qq release.zip + - run: find dist + - run: "touch dist/CNAME && echo \"${{ env.GH_PAGES_DOMAIN }}\" >> dist/CNAME" + - uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./dist + publish_dir: ./dist \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9d6c0e7..19b1931 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ dist dist-mirror cache +.env diff --git a/.woodpecker.yml b/.woodpecker.yml index fd58169..64cf16a 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,5 +1,4 @@ pipeline: - build_mirror: image: denoland/deno commands: @@ -7,11 +6,13 @@ pipeline: - apt install make - deno --version - make mirror - + when: + branch: [main] deploy_mirror: image: rclone/rclone commands: - "rclone sync dist-mirror/ :sftp:data/ --sftp-host frontier.gwei.cz --sftp-user pbw-deploy --sftp-port 2022 --sftp-pass $RCLONE_PASS -v" secrets: [RCLONE_PASS] when: - branch: [main] \ No newline at end of file + branch: [main] +branches: [main] \ No newline at end of file diff --git a/Makefile b/Makefile index c05311e..f56bc94 100644 --- a/Makefile +++ b/Makefile @@ -23,3 +23,6 @@ build-mirror: event-sync: deno run --unstable --allow-read --allow-write --allow-net utils/eventSync.js $(event) + +tag: + deno run --unstable --allow-run utils/tag.js \ No newline at end of file diff --git a/README.md b/README.md index 7a684b0..873390f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ to coordinate event listings. - 💽 Data: [data.prgblockweek.com](https://data.prgblockweek.com) - 🕵️ Explore: [explore.prgblockweek.com](https://explore.prgblockweek.com/) -You can use JSON Hero to view the data: [`/23/index.json` @ JSON Hero](https://jsonhero.io/new?url=https://data.prgblockweek.com/23/index.json) +You can use JSON Hero to view the data: +[`/23/index.json` @ JSON Hero](https://jsonhero.io/new?url=https://data.prgblockweek.com/23/index.json) ## Follow us! diff --git a/utils/tag.js b/utils/tag.js new file mode 100644 index 0000000..e1e569d --- /dev/null +++ b/utils/tag.js @@ -0,0 +1,9 @@ +const d = new Date(); +const tag = `v${d.getFullYear()}.${("0" + (d.getMonth() + 1)).slice(-2)}.${ + ("0" + d.getDate()).slice(-2) +}`; +const p = Deno.run({ cmd: ["git", "tag"], stdout: "piped" }); +const current = String.fromCharCode.apply(null, await p.output()).trim(); +const m = current.match(new RegExp(`${tag}`, "g")); +const num = m ? m.length : 0; +console.log(`TAG=${tag}-r${num}`);