Skip to content

Commit 1193afc

Browse files
committed
Format
1 parent ef2a306 commit 1193afc

File tree

1 file changed

+154
-154
lines changed

1 file changed

+154
-154
lines changed

.github/workflows/release.yml

Lines changed: 154 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,154 @@
1-
name: Release
2-
3-
on:
4-
push:
5-
tags:
6-
- 'v*'
7-
8-
permissions:
9-
contents: write
10-
11-
defaults:
12-
run:
13-
shell: bash
14-
15-
jobs:
16-
build:
17-
name: Build ${{ matrix.archive_suffix }}
18-
runs-on: ubuntu-latest
19-
strategy:
20-
fail-fast: false
21-
matrix:
22-
include:
23-
- goos: linux
24-
goarch: amd64
25-
archive_suffix: linux-x64
26-
binary_name: tsgo
27-
- goos: linux
28-
goarch: arm64
29-
archive_suffix: linux-arm64
30-
binary_name: tsgo
31-
- goos: darwin
32-
goarch: amd64
33-
archive_suffix: macos-x64
34-
binary_name: tsgo
35-
- goos: darwin
36-
goarch: arm64
37-
archive_suffix: macos-arm64
38-
binary_name: tsgo
39-
- goos: windows
40-
goarch: amd64
41-
archive_suffix: windows-x64
42-
binary_name: tsgo.exe
43-
44-
steps:
45-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
46-
47-
- uses: ./.github/actions/setup-go
48-
49-
- name: Determine version
50-
id: version
51-
run: |
52-
VERSION="${GITHUB_REF_NAME#v}"
53-
echo "version=$VERSION" >> $GITHUB_OUTPUT
54-
echo "VERSION=$VERSION" >> $GITHUB_ENV
55-
56-
- name: Build release archive
57-
id: package
58-
env:
59-
GOOS: ${{ matrix.goos }}
60-
GOARCH: ${{ matrix.goarch }}
61-
CGO_ENABLED: 0
62-
run: |
63-
set -euo pipefail
64-
65-
VERSION="${VERSION:?}"
66-
TARGET="typescript-go-${VERSION}-${{ matrix.archive_suffix }}"
67-
OUT_DIR="dist/${TARGET}"
68-
BIN_NAME="${{ matrix.binary_name }}"
69-
70-
mkdir -p "$OUT_DIR"
71-
72-
go build \
73-
-trimpath \
74-
-tags "noembed,release" \
75-
-ldflags "-s -w -X github.com/microsoft/typescript-go/internal/core.version=${VERSION}" \
76-
-o "$OUT_DIR/$BIN_NAME" \
77-
./cmd/tsgo
78-
79-
cp LICENSE "$OUT_DIR/"
80-
cp NOTICE.txt "$OUT_DIR/"
81-
82-
ARCHIVE_NAME="${TARGET}.zip"
83-
mkdir -p artifacts
84-
zip -9 -j "artifacts/${ARCHIVE_NAME}" "$OUT_DIR"/*
85-
86-
echo "archive-path=artifacts/${ARCHIVE_NAME}" >> "$GITHUB_OUTPUT"
87-
88-
- name: Upload release artifact
89-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
90-
with:
91-
name: tsgo-${{ matrix.archive_suffix }}-${{ steps.version.outputs.version }}
92-
path: ${{ steps.package.outputs.archive-path }}
93-
94-
publish:
95-
needs: build
96-
runs-on: ubuntu-latest
97-
steps:
98-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
99-
100-
- name: Download build artifacts
101-
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
102-
with:
103-
path: release
104-
merge-multiple: true
105-
106-
- name: Create source archive
107-
run: |
108-
set -euo pipefail
109-
110-
RAW_TAG="${GITHUB_REF_NAME}"
111-
VERSION="${RAW_TAG#v}"
112-
ARCHIVE_FOLDER="typescript-go-${VERSION}"
113-
ARCHIVE_NAME="${ARCHIVE_FOLDER}-source.zip"
114-
TMP_DIR="$(mktemp -d)"
115-
SOURCE_DIR="${TMP_DIR}/${ARCHIVE_FOLDER}"
116-
117-
mkdir -p "${SOURCE_DIR}"
118-
119-
rsync -a \
120-
--exclude='.git/' \
121-
--exclude='release/' \
122-
--exclude='node_modules/' \
123-
--exclude='testdata/' \
124-
./ "${SOURCE_DIR}/"
125-
126-
mkdir -p release
127-
(cd "${TMP_DIR}" && zip -9 -r "${GITHUB_WORKSPACE}/release/${ARCHIVE_NAME}" "${ARCHIVE_FOLDER}")
128-
129-
- name: Create or update GitHub release
130-
env:
131-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133-
run: |
134-
set -euo pipefail
135-
136-
RAW_TAG="${GITHUB_REF_NAME}"
137-
VERSION="${RAW_TAG#v}"
138-
TITLE="TypeScript Go ${VERSION}"
139-
NOTES="Release ${VERSION}"
140-
REPO="${GITHUB_REPOSITORY}"
141-
142-
shopt -s nullglob
143-
ASSETS=(release/*.zip)
144-
if [ ${#ASSETS[@]} -eq 0 ]; then
145-
echo "No release assets found" >&2
146-
exit 1
147-
fi
148-
149-
if gh release view "$RAW_TAG" --repo "$REPO" >/dev/null 2>&1; then
150-
gh release edit "$RAW_TAG" --repo "$REPO" --title "$TITLE" --notes "$NOTES"
151-
gh release upload "$RAW_TAG" "${ASSETS[@]}" --repo "$REPO" --clobber
152-
else
153-
gh release create "$RAW_TAG" "${ASSETS[@]}" --repo "$REPO" --title "$TITLE" --notes "$NOTES" --latest --verify-tag
154-
fi
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
jobs:
16+
build:
17+
name: Build ${{ matrix.archive_suffix }}
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- goos: linux
24+
goarch: amd64
25+
archive_suffix: linux-x64
26+
binary_name: tsgo
27+
- goos: linux
28+
goarch: arm64
29+
archive_suffix: linux-arm64
30+
binary_name: tsgo
31+
- goos: darwin
32+
goarch: amd64
33+
archive_suffix: macos-x64
34+
binary_name: tsgo
35+
- goos: darwin
36+
goarch: arm64
37+
archive_suffix: macos-arm64
38+
binary_name: tsgo
39+
- goos: windows
40+
goarch: amd64
41+
archive_suffix: windows-x64
42+
binary_name: tsgo.exe
43+
44+
steps:
45+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
46+
47+
- uses: ./.github/actions/setup-go
48+
49+
- name: Determine version
50+
id: version
51+
run: |
52+
VERSION="${GITHUB_REF_NAME#v}"
53+
echo "version=$VERSION" >> $GITHUB_OUTPUT
54+
echo "VERSION=$VERSION" >> $GITHUB_ENV
55+
56+
- name: Build release archive
57+
id: package
58+
env:
59+
GOOS: ${{ matrix.goos }}
60+
GOARCH: ${{ matrix.goarch }}
61+
CGO_ENABLED: 0
62+
run: |
63+
set -euo pipefail
64+
65+
VERSION="${VERSION:?}"
66+
TARGET="typescript-go-${VERSION}-${{ matrix.archive_suffix }}"
67+
OUT_DIR="dist/${TARGET}"
68+
BIN_NAME="${{ matrix.binary_name }}"
69+
70+
mkdir -p "$OUT_DIR"
71+
72+
go build \
73+
-trimpath \
74+
-tags "noembed,release" \
75+
-ldflags "-s -w -X github.com/microsoft/typescript-go/internal/core.version=${VERSION}" \
76+
-o "$OUT_DIR/$BIN_NAME" \
77+
./cmd/tsgo
78+
79+
cp LICENSE "$OUT_DIR/"
80+
cp NOTICE.txt "$OUT_DIR/"
81+
82+
ARCHIVE_NAME="${TARGET}.zip"
83+
mkdir -p artifacts
84+
zip -9 -j "artifacts/${ARCHIVE_NAME}" "$OUT_DIR"/*
85+
86+
echo "archive-path=artifacts/${ARCHIVE_NAME}" >> "$GITHUB_OUTPUT"
87+
88+
- name: Upload release artifact
89+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
90+
with:
91+
name: tsgo-${{ matrix.archive_suffix }}-${{ steps.version.outputs.version }}
92+
path: ${{ steps.package.outputs.archive-path }}
93+
94+
publish:
95+
needs: build
96+
runs-on: ubuntu-latest
97+
steps:
98+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
99+
100+
- name: Download build artifacts
101+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
102+
with:
103+
path: release
104+
merge-multiple: true
105+
106+
- name: Create source archive
107+
run: |
108+
set -euo pipefail
109+
110+
RAW_TAG="${GITHUB_REF_NAME}"
111+
VERSION="${RAW_TAG#v}"
112+
ARCHIVE_FOLDER="typescript-go-${VERSION}"
113+
ARCHIVE_NAME="${ARCHIVE_FOLDER}-source.zip"
114+
TMP_DIR="$(mktemp -d)"
115+
SOURCE_DIR="${TMP_DIR}/${ARCHIVE_FOLDER}"
116+
117+
mkdir -p "${SOURCE_DIR}"
118+
119+
rsync -a \
120+
--exclude='.git/' \
121+
--exclude='release/' \
122+
--exclude='node_modules/' \
123+
--exclude='testdata/' \
124+
./ "${SOURCE_DIR}/"
125+
126+
mkdir -p release
127+
(cd "${TMP_DIR}" && zip -9 -r "${GITHUB_WORKSPACE}/release/${ARCHIVE_NAME}" "${ARCHIVE_FOLDER}")
128+
129+
- name: Create or update GitHub release
130+
env:
131+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
run: |
134+
set -euo pipefail
135+
136+
RAW_TAG="${GITHUB_REF_NAME}"
137+
VERSION="${RAW_TAG#v}"
138+
TITLE="TypeScript Go ${VERSION}"
139+
NOTES="Release ${VERSION}"
140+
REPO="${GITHUB_REPOSITORY}"
141+
142+
shopt -s nullglob
143+
ASSETS=(release/*.zip)
144+
if [ ${#ASSETS[@]} -eq 0 ]; then
145+
echo "No release assets found" >&2
146+
exit 1
147+
fi
148+
149+
if gh release view "$RAW_TAG" --repo "$REPO" >/dev/null 2>&1; then
150+
gh release edit "$RAW_TAG" --repo "$REPO" --title "$TITLE" --notes "$NOTES"
151+
gh release upload "$RAW_TAG" "${ASSETS[@]}" --repo "$REPO" --clobber
152+
else
153+
gh release create "$RAW_TAG" "${ASSETS[@]}" --repo "$REPO" --title "$TITLE" --notes "$NOTES" --latest --verify-tag
154+
fi

0 commit comments

Comments
 (0)