-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(release): splits release/pre-release into separate workflows
- Loading branch information
Showing
2 changed files
with
200 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
name: Pre-release | ||
on: | ||
push: | ||
tags: | ||
- 'v*-rc*' # Matches tags like v2.0.0-rc1, v2.0.0-rc2, etc. | ||
|
||
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: ubuntu-latest | ||
platform: linux | ||
arch: i686 | ||
code-target: linux-x86 | ||
- 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 | ||
- os: windows-latest | ||
platform: windows | ||
arch: i686 | ||
code-target: win32-x86 | ||
|
||
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: 16 | ||
|
||
- name: Determine treefmt version and filename | ||
id: determine-version | ||
run: | | ||
if [[ "${{ matrix.platform }}" == 'windows' ]]; then | ||
echo "PRERELEASE=false" >> $GITHUB_ENV | ||
case "${{ matrix.arch }}" in | ||
"amd64") FILENAME="treefmt-x86_64-pc-windows-msvc.zip";; | ||
"arm64") FILENAME="treefmt-aarch64-pc-windows-msvc.zip";; | ||
"i686") FILENAME="treefmt-i686-pc-windows-msvc.zip";; | ||
*) echo "Unsupported platform/arch combination" && exit 1;; | ||
esac | ||
else | ||
echo "PRERELEASE=true" >> $GITHUB_ENV | ||
case "${{ matrix.platform }}-${{ matrix.arch }}" in | ||
"linux-amd64") FILENAME="treefmt_2.0.0-rc*_linux_amd64.tar.gz";; | ||
"linux-arm64") FILENAME="treefmt_2.0.0-rc*_linux_arm64.tar.gz";; | ||
"linux-i686") FILENAME="treefmt_2.0.0-rc*_linux_386.tar.gz";; | ||
"darwin-amd64") FILENAME="treefmt_2.0.0-rc*_darwin_amd64.tar.gz";; | ||
"darwin-arm64") FILENAME="treefmt_2.0.0-rc*_darwin_arm64.tar.gz";; | ||
*) echo "Unsupported platform/arch combination" && exit 1;; | ||
esac | ||
fi | ||
echo "FILENAME=$FILENAME" >> $GITHUB_ENV | ||
- name: Download treefmt | ||
id: download-release | ||
uses: robinraju/[email protected] | ||
with: | ||
repository: "numtide/treefmt" | ||
latest: true | ||
preRelease: ${{ env.PRERELEASE }} | ||
fileName: ${{ env.FILENAME }} | ||
out-file-path: "downloads" | ||
extract: true | ||
|
||
- name: Rename treefmt binary | ||
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 | ||
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 | ||
with: | ||
name: vsix | ||
|
||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
treefmt-*.vsix | ||
prerelease: true | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters