diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..6f1c752 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,52 @@ +name: Main +on: + pull_request: + push: +jobs: + main: + runs-on: ubuntu-latest + steps: + + - name: checkout repo + uses: actions/checkout@v3 + + - name: install nix + uses: cachix/install-nix-action@v18 + + - name: check flake + run: nix flake check + + - name: build package + id: package + run: | + nix build + echo ::set-output name=path::result/*.vsix + + - name: get latest tag + id: latest + run: echo ::set-output name=version::$(git describe --abbrev=0 --tags --match 'v[0-9]*\.[0-9]*\.[0-9]*' | cut -c2-) + + - name: parse changelog + id: changelog + uses: coditory/changelog-parser@v1 + + - name: create release + uses: softprops/action-gh-release@v1 + if: github.ref == 'refs/heads/main' && steps.changelog.outputs.version != steps.latest.outputs.version + with: + files: ${{ steps.package.outputs.path }} + body: ${{ steps.changelog.outputs.description }} + tag_name: ${{ steps.changelog.outputs.version }} + + - name: publish to Open VSX + uses: HaaLeo/publish-vscode-extension@v1 + with: + pat: ${{ secrets.OPENVSX_ACCESS_TOKEN }} + extensionFile: ${{ steps.package.outputs.path }} + + - name: publish to VS Marketplace + uses: HaaLeo/publish-vscode-extension@v1 + with: + pat: ${{ secrets.AZURE_ACCESS_TOKEN }} + registryUrl: https://marketplace.visualstudio.com + extensionFile: ${{ steps.package.outputs.path }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9632f0b..4f27fdc 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ test/resources/assets test-results.xml index.scip -.direnv/ \ No newline at end of file +.direnv/ +result \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 92fa7c9..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,129 +0,0 @@ -include: - - template: SAST.gitlab-ci.yml - - template: Dependency-Scanning.gitlab-ci.yml - - template: License-Scanning.gitlab-ci.yml - - template: Secret-Detection.gitlab-ci.yml - -# run the pipeline only on MRs and default branch -workflow: - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - - when: never - -image: node:16 - -stages: - - test - - package - - publish - -lint: - stage: test - script: - - npm ci - - npm run lint - -test: - stage: test - variables: - DISPLAY: ":99.0" - before_script: - - | - (apt-get update && apt-get install -y \ - libasound2-dev \ - libatk-bridge2.0-dev \ - libatk1.0-dev \ - libdrm-dev \ - libgtk-3-dev \ - libnss3 \ - xvfb) > /dev/null - - Xvfb -ac :99 -screen 0 1920x1080x16 & - - dbus-daemon --system & - script: - - npm ci - - npm run test - artifacts: - when: always - reports: - junit: - - test-results.xml - -## currently returns a 500: https://gitlab.com/hall/draw/-/jobs/2520086017 -# navigation: -# stage: test -# image: sourcegraph/scip-typescript:v0 -# allow_failure: true # recommended -# rules: -# - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH -# script: -# - scip-typescript index -# artifacts: -# reports: -# lsif: index.scip - -package: - stage: package - script: - - npm ci - - npx vsce package - rules: - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - artifacts: - expire_in: 1 mos - paths: - - "*.vsix" - -publish: - stage: publish - rules: - - changes: - - CHANGELOG.md - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - before_script: - - apt update && apt install -y jq - script: - - | # if unpublished version was bumped in CHANGELOG, push a tag - set -eo pipefail - - # use the CHANGELOG as the source of truth - CURRENT=$(perl -lne 'print for /## \[(\d*\.\d*\.\d*)\] /' CHANGELOG.md | head -1) - - PACKAGE=$(jq -r '.version' package.json) - if [[ "$CURRENT" != "$PACKAGE" ]]; then - echo "ERROR: package.json version ($PACKAGE) does not match CHANGELOG version ($CURRENT)" - exit 1 - fi - - LATEST=$(npx vsce show hall.draw --json | jq -r '.versions[0].version') - if [[ "$CURRENT" == "$LATEST" ]]; then - exit 0 - fi - - git tag "$CURRENT" - git remote set-url origin "https://git:$GITLAB_PAT@$CI_SERVER_HOST/$CI_PROJECT_PATH" - git push origin "$CURRENT" - - npx ovsx publish *.vsix -p $OPENVSX_ACCESS_TOKEN - npx vsce publish --packagePath *.vsix -p $AZURE_ACCESS_TOKEN - -# https://gitlab.com/gitlab-org/gitlab-vscode-extension/-/blob/main/.gitlab-ci.yml -# run security scanning on every pipeline execution; https://gitlab.com/gitlab-org/gitlab/-/issues/217668 -.secure-jobs-config: &secure-jobs-config - needs: [] - rules: - - when: on_success -gemnasium-dependency_scanning: - <<: *secure-jobs-config -license_scanning: - <<: *secure-jobs-config -eslint-sast: - <<: *secure-jobs-config -nodejs-scan-sast: - <<: *secure-jobs-config -secret_detection: - <<: *secure-jobs-config - # secrets detection can't run on tags: https://gitlab.com/gitlab-org/gitlab/-/issues/254199 - rules: - - if: $CI_COMMIT_TAG - when: "never" diff --git a/flake.lock b/flake.lock index afd0e90..d272427 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1671411992, - "narHash": "sha256-ghcAFBNXvYMD/X7zCMuiwYFbWxaoDyrC5xiTpMQgaSQ=", + "lastModified": 1673403193, + "narHash": "sha256-OOKrw6SDyMhVsXAFw4zwycjhrDq+ICzWyW0/PSTHTdM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "95109997bb730f4dc2d8971db603df3559c5bbcc", + "rev": "b0644b461f97d4f7240b089074084c18f521f497", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 1e519a4..2c1129d 100644 --- a/flake.nix +++ b/flake.nix @@ -8,44 +8,22 @@ inputs.utils.lib.eachDefaultSystem (system: let pkgs = inputs.nixpkgs.legacyPackages.${system}; in { - devShell = (pkgs.buildFHSUserEnvBubblewrap { - name = "fhs"; - runScript = "bash"; - targetPkgs = pkgs: with pkgs; [ - # dev - nodejs - gitlab-runner - - # test - alsa-lib - at-spi2-atk - at-spi2-core - atk - cairo - dbus - expat - gdk-pixbuf - glib - gtk3 - libdrm - libxkbcommon - mesa - nspr - nss - pango - xorg.libX11 - xorg.libXcomposite - xorg.libXdamage - xorg.libXext - xorg.libXfixes - xorg.libXrandr - xorg.libxcb - - libdbusmenu - (lib.getLib systemd) - fontconfig.lib + packages.default = pkgs.buildNpmPackage { + name = "draw"; + src = ./.; + npmDepsHash = "sha256-/aW1tyzE6WK4zBAOep4BhBM4W6/ZjpoBEpZ50eMVnM4="; + nativeBuildInputs = with pkgs; [ + pkg-config + python3 + ]; + buildInputs = with pkgs; [ + libsecret ]; - }).env; + installPhase = '' + mkdir -p $out + cp ./*.vsix $out/ + ''; + }; }); } diff --git a/package.json b/package.json index 8323bed..28ed710 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,10 @@ "icon": "docs/images/icon.png", "license": "Apache-2.0", "repository": { - "url": "https://gitlab.com/hall/draw" + "url": "https://github.com/hall/draw" }, "bugs": { - "url": "https://gitlab.com/hall/draw/issues" + "url": "https://github.com/hall/draw/issues" }, "engines": { "vscode": "^1.53.0" @@ -94,7 +94,7 @@ "draw.buttons": { "type": "array", "default": [], - "markdownDescription": "Add [custom buttons](https://gitlab.com/hall/draw#custom-buttons) to the toolbar", + "markdownDescription": "Add [custom buttons](https://github.com/hall/draw#custom-buttons) to the toolbar", "items": { "type": "object", "additionalProperties": false, @@ -133,7 +133,8 @@ "package": "webpack --mode production --devtool hidden-source-map", "lint": "eslint . --ext .ts,.tsx", "pretest": "tsc -p ./", - "test": "extest setup-and-run ./out/**/*.test.js" + "test": "extest setup-and-run ./out/**/*.test.js", + "build": "npx vsce package" }, "dependencies": { "@fortawesome/fontawesome-free": "^6.1.1",