Skip to content

Commit

Permalink
feat(release): splits release/pre-release into separate workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
isbecker committed Jun 25, 2024
1 parent 0e17b41 commit f3138ee
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 78 deletions.
157 changes: 157 additions & 0 deletions .github/workflows/pre-release.yml
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
121 changes: 43 additions & 78 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Release
on:
push:
branches:
- 'release/**'
- 'beta/**'
tags:
- 'v*.*.*' # Matches tags like v1.0.0, v2.0.0, etc., but not pre-releases

env:
FETCH_DEPTH: 0 # pull in the tags for the version string
Expand Down Expand Up @@ -66,41 +65,19 @@ jobs:
- name: Determine treefmt version and filename
id: determine-version
run: |
if [[ "${{ github.ref }}" == refs/heads/release/* ]]; then
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";;
"linux-i686") FILENAME="treefmt-i686-unknown-linux-musl.tar.gz";;
"linux-arm") FILENAME="treefmt-arm-unknown-linux-musleabihf.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";;
"windows-i686") FILENAME="treefmt-i686-pc-windows-msvc.zip";;
*) echo "Unsupported platform/arch combination" && exit 1;;
esac
elif [[ "${{ github.ref }}" == refs/heads/beta/* ]]; then
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
fi
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";;
"linux-i686") FILENAME="treefmt-i686-unknown-linux-musl.tar.gz";;
"linux-arm") FILENAME="treefmt-arm-unknown-linux-musleabihf.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";;
"windows-i686") FILENAME="treefmt-i686-pc-windows-msvc.zip";;
*) echo "Unsupported platform/arch combination" && exit 1;;
esac
echo "FILENAME=$FILENAME" >> $GITHUB_ENV
- name: Download treefmt
Expand All @@ -109,7 +86,6 @@ jobs:
with:
repository: "numtide/treefmt"
latest: true
preRelease: ${{ env.PRERELEASE }}
fileName: ${{ env.FILENAME }}
out-file-path: "downloads"
extract: true
Expand All @@ -130,59 +106,48 @@ jobs:
- name: Package Extension
run: npx vsce package -o "./treefmt-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }}

- name: Upload artifacts
- name: Upload VSIX
uses: actions/upload-artifact@v4
with:
name: pkg-${{ matrix.target }}
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
name: Publish
name: Publish Extension
runs-on: ubuntu-latest
needs: package
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download VSIX
uses: actions/download-artifact@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}
name: vsix

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- uses: actions/download-artifact@v4
with:
name: pkg-aarch64-apple-darwin
path: pkg
- uses: actions/download-artifact@v4
with:
name: pkg-x86_64-apple-darwin
path: pkg
- uses: actions/download-artifact@v4
with:
name: pkg-x86_64-unknown-linux-gnu
path: pkg
- uses: actions/download-artifact@v4
with:
name: pkg-aarch64-unknown-linux-gnu
path: pkg
- uses: actions/download-artifact@v4
with:
name: pkg-x86_64-pc-windows-msvc
path: pkg
- uses: actions/download-artifact@v4
with:
name: pkg-arm64-pc-windows-msvc
path: pkg
- uses: actions/download-artifact@v4
with:
name: pkg-i686-pc-windows-msvc
path: pkg

- name: Publish Extension (Marketplace)
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ./pkg/treefmt-*.vsix
- name: Publish to Marketplace
run: npx vsce publish --packagePath treefmt-*.vsix --pat ${{ secrets.MARKETPLACE_TOKEN }}

# - name: Publish Extension (OpenVSX)
# run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ./pkg/treefmt-*.vsix
# - name: Publish to OpenVSX
# run: npx ovsx publish --packagePath treefmt-*.vsix --pat ${{ secrets.OPENVSX_TOKEN }}
# timeout-minutes: 2

0 comments on commit f3138ee

Please sign in to comment.