Skip to content

Commit

Permalink
Merge pull request #69 from nitech-create:refactor
Browse files Browse the repository at this point in the history
リファクタリング & バグ修正 & Chrome Web Storeでの公開を記述
  • Loading branch information
KoCSience authored Nov 12, 2024
2 parents 151031d + c4a4286 commit 6892e36
Show file tree
Hide file tree
Showing 104 changed files with 2,921 additions and 2,598 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/check-version-increase.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/check-version-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Check Version Increase

on:
pull_request:
types:
- opened
- synchronize
branches:
- main
paths:
- "src/**"

jobs:
get-main-version:
uses: ./.github/workflows/manifest-version.yml
with:
ref: refs/heads/main
checkout-ref: main

get-current-version:
uses: ./.github/workflows/manifest-version.yml
with:
ref: ${{ github.event.pull_request.head.sha }}

check-version:
runs-on: ubuntu-latest
needs: [get-main-version, get-current-version]

steps:
- run: |
echo "current: ${{ needs.get-current-version.outputs.version }}"
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: compare versions
env:
MAIN_VERSION: ${{ needs.get-main-version.outputs.version }}
CURRENT_VERSION: ${{ needs.get-current-version.outputs.version }}
run: test "$MAIN_VERSION" != "$CURRENT_VERSION"
39 changes: 12 additions & 27 deletions .github/workflows/create-tag-on-pr-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,25 @@ on:
types:
- closed
paths:
- 'src/**'
- "src/**"

jobs:
get-version:
uses: ./.github/workflows/manifest-version.yml
with:
ref: ${{ github.event.pull_request.head.sha }}

create-tag:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
needs: get-version
timeout-minutes: 1

steps:
- uses: actions/checkout@v3

- name: Extract version
run: echo "VERSION=v$(sh scripts/get-manifest-version.sh)" >> $GITHUB_ENV

- name: Get commit URL
env:
COMMITS_URL: ${{ github.event.pull_request.base.repo.commits_url }}
SHA: ${{ github.sha }}
run: echo "COMMIT_URL=$COMMITS_URL" | sed -e "s#{/sha}#/$SHA#" >> $GITHUB_ENV
- uses: actions/checkout@v4

- name: Get commit message
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "MESSAGE<<$EOF" >> $GITHUB_ENV
JSON_TEXT=$(curl -s -L -H "Accept: application/vnd.github+json" $COMMIT_URL)
VERSION_STRING=$(echo "$JSON_TEXT" | jq ".commit.message" | sed -E 's/^"//' | sed -E 's/"$//')
echo -e "$VERSION_STRING" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: create tag
run: git tag ${{ needs.get-version.outputs.version }}

- name: Add tag ${{ env.VERSION }}
uses: rickstaa/action-create-tag@v1
id: create-tag
with:
tag: ${{ env.VERSION }}
tag_exists_error: true
commit_sha: ${{ github.sha }}
message: ${{ env.MESSAGE }}
- name: push tag
run: git push origin ${{ needs.get-version.outputs.version }}
28 changes: 0 additions & 28 deletions .github/workflows/lint-fmt-test.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Lint and Check Format

on: push

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 3

steps:
- uses: actions/checkout@v4

- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: lint
run: deno lint

format:
runs-on: ubuntu-latest
timeout-minutes: 3

steps:
- uses: actions/checkout@v4

- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: check format
run: deno fmt --check

build:
runs-on: ubuntu-latest
timeout-minutes: 3

steps:
- uses: actions/checkout@v4

- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: build
run: deno task build
41 changes: 41 additions & 0 deletions .github/workflows/manifest-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Manifest Version

on:
workflow_call:
inputs:
ref:
required: true
type: string
checkout-ref:
type: string
outputs:
version:
value: ${{ jobs.get-version.outputs.version }}

jobs:
get-version:
runs-on: ubuntu-latest
timeout-minutes: 3

outputs:
version: ${{ steps.get-version.outputs.version }}

steps:
- run: 'echo "ref: ${{ inputs.ref }}"'

- uses: actions/checkout@v4
with:
ref: ${{ inputs.checkout-ref || inputs.ref }}

- uses: actions/checkout@v4

- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: get version
id: get-version
run: |
VERSION=$(NOCOLOR="true" git show "${{ inputs.ref }}:./src/manifest.jsonc" | deno run scripts/getManifestVersion.ts)
echo "Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
58 changes: 0 additions & 58 deletions .github/workflows/release-attach-artifact-manual.yml

This file was deleted.

41 changes: 16 additions & 25 deletions .github/workflows/release-attach-artifact.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,36 @@
name: attach build artifact to release
name: "Release: Attach Artifact"

on:
release:
types:
- published
- released
- prereleased

permissions: write-all

env:
TEMP_ASSET_NAME: asset.zip
FILE_NAME: nitech-moodle-extension-40a-${{ github.event.release.tag_name }}.zip

jobs:
attach-build-artifact:
runs-on: ubuntu-latest
timeout-minutes: 1
timeout-minutes: 3

steps:
- uses: actions/checkout@v3

- name: Set environment variables
env:
TAG_NAME: ${{ github.event.release.tag_name }}
run: |
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
- uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v1
- uses: denoland/setup-deno@v2
with:
deno-version: v1.x
deno-version: v2.x

- name: Build
- name: build
run: deno task build

- name: Create zip
run: cd ./dist; zip $TEMP_ASSET_NAME -r .
- name: zip artifacts
run: cd ./dist; zip $FILE_NAME -r .

- name: Upload release asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
- name: upload
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dist/${{ env.TEMP_ASSET_NAME }}
asset_name: nitech-moodle-extension-40a-${{ env.TAG_NAME }}.zip
asset_content_type: application/zip
run: |
gh release upload ${{ github.event.release.tag_name }} $FILE_NAME
28 changes: 0 additions & 28 deletions build.ts

This file was deleted.

Loading

0 comments on commit 6892e36

Please sign in to comment.