-
Notifications
You must be signed in to change notification settings - Fork 31
146 lines (121 loc) · 5.1 KB
/
autorelease.yml
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
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Create Version and Tag
# If you change this name, don't forget to change the name in 'deploy.yml'!
on:
schedule:
- cron: '0 3 * * 1' # Every Monday at 3am UTC
workflow_dispatch: # For manual triggering
env:
JAVA_VERSION: '11'
NODE_VERSION: '12.x'
jobs:
run-tests: # redux of usual CI defined in `ci.yml`
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'zulu'
cache: 'sbt'
- name: Set up NodeJS ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install MLton
run: |
curl -L https://github.com/MLton/mlton/releases/download/on-20210117-release/mlton-20210117-1.amd64-linux-glibc2.31.tgz --output mlton.tgz
tar -xzf mlton.tgz
mv mlton-20210117-1.amd64-linux-glibc2.31 $GITHUB_WORKSPACE/mlton
chmod +x $GITHUB_WORKSPACE/mlton/bin/mlton
echo "Trying to call directly"
$GITHUB_WORKSPACE/mlton/bin/mlton
echo "Adding mlton to path"
echo "$GITHUB_WORKSPACE/mlton/bin" >> $GITHUB_PATH
- name: Install Chez Scheme, LLVM & libuv
run: sudo apt-get install -y chezscheme llvm-15 libuv1-dev
- name: Run tests with retry
uses: nick-fields/retry@v3
with:
timeout_minutes: 120 # NOTE: This needs _some_ value. As of writing this, 2 hours should be future-proof. :)
max_attempts: 3
retry_on: error
command: sbt clean test
new_command_on_retry: sbt testQuick # should only rerun failed tests
bump-version-and-tag:
name: Bump Version and Create Tag
runs-on: ubuntu-latest
needs: [run-tests]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'true'
# No need to setup environment again
- name: Bump Effekt version using sbt
id: set-version
run: |
# Capture the output of 'sbt bumpMinorVersion'
full_output=$(sbt 'bumpMinorVersion' -error)
# Extract the actual version number using grep
new_version=$(echo "$full_output" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | tail -n 1)
# Trim any potential whitespace
new_version=$(echo "$new_version" | xargs)
# Check that the new_version is actually non-empty and looks like a version number
if [[ ! $new_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version bump failed. Invalid version number: '${new_version}'"
echo "Full output was:"
echo "$full_output"
exit 1
fi
echo "VERSION=${new_version}" >> $GITHUB_OUTPUT
echo "Successfully set new version: ${new_version}"
- name: Update Effekt version in NPM and MVN via sbt
run: sbt updateVersions
# Login as a GitHub App in order to bypass rules about committing to `master` directly
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.EFFEKT_UPDATER_GH_APP_ID }}
private-key: ${{ secrets.EFFEKT_UPDATER_GH_CREDENTIALS_TOKEN }}
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Debug GitHub App authentication
run: |
echo "Authenticated user:"
gh api user --jq '{login: .login, id: .id, type: .type}'
echo "Repository permissions:"
gh api repos/${{ github.repository }} --jq '.permissions'
echo "Branch protection rules:"
gh api repos/${{ github.repository }}/branches/${{ github.ref_name }}/protection --jq '.restrictions'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Commit and push changes
run: |
echo "Verifying token and auth status:"
gh auth status
echo "Attempting explicit login:"
echo "${{ steps.app-token.outputs.token }}" | gh auth login --with-token
gh auth status
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'
git add project/EffektVersion.scala
git add package.json
git add pom.xml
git commit -m "Bump version to ${{ steps.set-version.outputs.VERSION }}"
git push
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Create and push tag
run: |
git tag v${{ steps.set-version.outputs.VERSION }}
git push origin v${{ steps.set-version.outputs.VERSION }}
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}