Create Release #3
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
name: Create Release | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'src/manifest.json' | |
workflow_dispatch: # allows to manually trigger the workflow_dispatch | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
sudo apt install jq | |
- name: Set up Git user | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email '[email protected]' | |
- name: Load .env file | |
run: | | |
set -o allexport | |
source .env | |
set +o allexport | |
# Export all loaded variables to GITHUB_ENV | |
for var in $(cat .env | grep -v '^#' | xargs); do | |
echo "$var" >> $GITHUB_ENV | |
done | |
- name: Extract version number | |
id: extract_version | |
run: echo "VERSION=$(jq -r '.version' src/manifest.json)" >> $GITHUB_ENV | |
- name: Check changelog for version entry | |
run: | | |
if ! grep -q "## v${VERSION}" "${CHANGELOG}"; then | |
echo "Error: ${CHANGELOG} does not contain a heading for version v${VERSION}." | |
exit 1 | |
fi | |
- name: Build release | |
run: | | |
echo "Building release ${BASE_NAME}-$VERSION" | |
chmod +x scripts/build.sh | |
scripts/build.sh ${BASE_NAME} $VERSION | |
echo "Built release ${BASE_NAME}-$VERSION" | |
- name: Get release notes | |
run: | | |
echo "Extract release notes from ${CHANGELOG}" | |
echo "## Changes" >> release-notes-${VERSION}.md | |
sed -n "/## v${VERSION}/,/^## /p" ${CHANGELOG} | sed '1d;$d' >> release-notes-${VERSION}.md | |
echo "Extracted release notes from ${CHANGELOG}" | |
- name: Create release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "Creating release $VERSION" | |
gh release create v${VERSION} ${BUILD_DIR}/${BASE_NAME}-${VERSION}.xpi -t "v${VERSION}" --notes-file release-notes-${VERSION}.md | |
echo "Created release $VERSION" | |
- name: Cleanup | |
run: | | |
rm release-notes-${VERSION}.md | |
rm -rf ${BUILD_DIR} |