Skip to content

fix(ci): adds write permission for github release creation #7

fix(ci): adds write permission for github release creation

fix(ci): adds write permission for github release creation #7

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*.*.*' # Matches tags like v1.0.0, v2.0.0, etc., but not pre-releases
permissions:
contents: write
env:
FETCH_DEPTH: 0 # pull in the tags for the version string
jobs:
package:
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
arch: amd64
code-target: linux-x64
- os: ubuntu-latest
platform: linux
arch: arm64
code-target: linux-arm64
- os: macos-latest
platform: darwin
arch: amd64
code-target: darwin-x64
- os: macos-latest
platform: darwin
arch: arm64
code-target: darwin-arm64
- os: windows-latest
platform: windows
arch: amd64
code-target: win32-x64
- os: windows-latest
platform: windows
arch: arm64
code-target: win32-arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Determine treefmt version and filename
id: determine-version
shell: bash
run: |
echo "PRERELEASE=false" >> $GITHUB_ENV
case "${{ matrix.platform }}-${{ matrix.arch }}" in
"linux-amd64") FILENAME="treefmt-x86_64-unknown-linux-gnu.tar.gz";;
"linux-arm64") FILENAME="treefmt-aarch64-unknown-linux-musl.tar.gz";;
"darwin-amd64") FILENAME="treefmt-x86_64-apple-darwin.tar.gz";;
"darwin-arm64") FILENAME="treefmt-aarch64-apple-darwin.tar.gz";;
"windows-amd64") FILENAME="treefmt-x86_64-pc-windows-msvc.zip";;
"windows-arm64") FILENAME="treefmt-aarch64-pc-windows-msvc.zip";;
*) echo "Unsupported platform/arch combination" && exit 1;;
esac
echo "FILENAME=$FILENAME" >> $GITHUB_ENV
- name: Download treefmt
id: download-release
uses: robinraju/[email protected]
with:
repository: "numtide/treefmt"
latest: true
fileName: ${{ env.FILENAME }}
out-file-path: "downloads"
extract: true
- name: Rename treefmt binary
shell: bash
run: |
mkdir -p bin
if [[ "${{ matrix.platform }}" == 'windows' ]]; then
mv downloads/treefmt.exe bin/treefmt
else
mv downloads/treefmt bin/treefmt
fi
chmod +x bin/treefmt
- name: Install dependencies
run: npm ci
- name: Package Extension
run: npx vsce package -o "./treefmt-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }}
- name: Upload VSIX
uses: actions/upload-artifact@v4
with:
name: vsix-${{ matrix.platform }}-${{ matrix.arch }}
path: "./treefmt-${{ matrix.code-target }}.vsix"
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: package
steps:
- name: Download VSIX
uses: actions/download-artifact@v4
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
treefmt-*.vsix
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
name: Publish Extension
runs-on: ubuntu-latest
needs: package
steps:
- name: Download VSIX
uses: actions/download-artifact@v4
with:
name: vsix
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Publish to Marketplace
run: npx vsce publish --packagePath treefmt-*.vsix --pat ${{ secrets.MARKETPLACE_TOKEN }}
# - name: Publish to OpenVSX
# run: npx ovsx publish --packagePath treefmt-*.vsix --pat ${{ secrets.OPENVSX_TOKEN }}
# timeout-minutes: 2