diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..7152a8a --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,106 @@ +name: Build and Test + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: archlinux + container: + image: node:25 + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Install mise + run: | + curl -fsSL https://mise.run | sh + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + + - name: Install pnpm + run: | + export PATH="$HOME/.local/bin:$PATH" + mise trust + mise install pnpm + mise reshim + echo "$HOME/.local/share/mise/shims" >> "$GITHUB_PATH" + + - name: Install just + run: | + curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin + + - name: Install system dependencies + run: | + apt-get update + apt-get install -y libglib2.0-dev glib-networking zip + + - name: Install project dependencies + run: pnpm install --frozen-lockfile --ignore-scripts + + - name: Build and package extension + run: just build-package + + - name: Upload extension package + uses: actions/upload-artifact@v3 + with: + name: prettyborders-extension + path: prettyborders.zip + retention-days: 30 + + release: + needs: build + runs-on: archlinux + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + environment: + name: production + container: + image: node:25 + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: prettyborders-extension + + - name: Get version from package.json + id: get_version + run: | + VERSION=$(node -p "require('./package.json').version") + echo "version=v${VERSION}" >> $GITHUB_OUTPUT + + - name: Create Gitea Release + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + run: | + curl -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + -d '{ + "tag_name": "${{ steps.get_version.outputs.version }}", + "name": "Release ${{ steps.get_version.outputs.version }}", + "body": "Automated release of prettyborders GNOME extension ${{ steps.get_version.outputs.version }}\n\n## Installation\nDownload prettyborders.zip and install it as a GNOME extension." + }' \ + "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases" + + - name: Upload Release Asset + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + run: | + RELEASE_ID=$(curl -H "Authorization: token ${GITEA_TOKEN}" \ + "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${{ steps.get_version.outputs.version }}" | \ + grep -Po '"id":\s*\K[0-9]+' | head -1) + + curl -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: multipart/form-data" \ + -F "attachment=@prettyborders.zip" \ + "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=prettyborders.zip" diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..a3a76a2 --- /dev/null +++ b/mise.toml @@ -0,0 +1,2 @@ +[tools] +pnpm = "latest"