forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (133 loc) · 4.57 KB
/
publish.yml
File metadata and controls
133 lines (133 loc) · 4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Publish
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
release:
name: Packages
if: github.repository == 'AssemblyScript/assemblyscript'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: current
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Build packages
id: build
run: |
VERSION=$(npx aspublish --version)
if [[ "$VERSION" == "" ]]; then
echo "Changes do not trigger a release"
echo "should_publish=false" >> $GITHUB_OUTPUT
elif [[ "$VERSION" != "0."* ]]; then
echo "Unexpected version: $VERSION"
exit 1
else
echo "Building version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "should_publish=true" >> $GITHUB_OUTPUT
npm version "$VERSION" --no-git-tag-version
npm run build
npm test
cd lib/loader
npm version "$VERSION" --no-git-tag-version
npm run build
npm test
cd ../rtrace
npm version "$VERSION" --no-git-tag-version
npm run build
npm test
cd ../..
fi
- name: Determine npm tag
if: steps.build.outputs.should_publish == 'true'
id: npm_tag
run: |
VERSION="${{ steps.build.outputs.version }}"
if [[ "$VERSION" == *"-alpha"* ]]; then
echo "tag=alpha" >> $GITHUB_OUTPUT
echo "prerelease=true" >> $GITHUB_OUTPUT
elif [[ "$VERSION" == *"-beta"* ]]; then
echo "tag=beta" >> $GITHUB_OUTPUT
echo "prerelease=true" >> $GITHUB_OUTPUT
elif [[ "$VERSION" == *"-rc"* ]]; then
echo "tag=rc" >> $GITHUB_OUTPUT
echo "prerelease=true" >> $GITHUB_OUTPUT
else
echo "tag=latest" >> $GITHUB_OUTPUT
echo "prerelease=false" >> $GITHUB_OUTPUT
fi
- name: Publish packages
if: steps.build.outputs.should_publish == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
NPM_TAG="${{ steps.npm_tag.outputs.tag }}"
node ./scripts/prepublish
if [ $(node -pe "require('./package.json').version") != "0.0.0" ]; then
npx aspublish --tag "$NPM_TAG"
fi
cd lib/loader
if [ $(node -pe "require('./package.json').version") != "0.0.0" ]; then
npm publish --access public --tag "$NPM_TAG"
fi
cd ../rtrace
if [ $(node -pe "require('./package.json').version") != "0.0.0" ]; then
npm publish --access public --tag "$NPM_TAG"
fi
cd ../..
node ./scripts/prepublish --reset
- name: Generate changelog
if: steps.build.outputs.should_publish == 'true'
id: changelog
uses: mikepenz/release-changelog-builder-action@v6
with:
configurationJson: |
{
"categories": [
{
"title": "### Breaking Changes",
"labels": ["breaking", "breaking-change"]
},
{
"title": "### Features",
"labels": ["feature", "feat", "enhancement"]
},
{
"title": "### Bug Fixes",
"labels": ["bug", "fix", "bugfix"]
},
{
"title": "### Other Changes",
"labels": []
}
],
"template": "#{{CHANGELOG}}",
"pr_template": "- #{{TITLE}} ([##{{NUMBER}}](#{{URL}})) by @#{{AUTHOR}}",
"empty_template": "- No changes",
"tag_resolver": {
"method": "semver"
}
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub release
if: steps.build.outputs.should_publish == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.build.outputs.version }}
name: Release v${{ steps.build.outputs.version }}
body: ${{ steps.changelog.outputs.changelog }}
prerelease: ${{ steps.npm_tag.outputs.prerelease == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}